@floless/app 0.148.0 → 0.149.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/bin/floless.mjs +1 -1
- package/dist/floless-server.cjs +29419 -19062
- package/dist/schemas/drawing-check.profile.v1.schema.json +156 -0
- package/dist/schemas/steel.model.v2.schema.json +43 -1
- package/dist/schemas/tekla.model.v2.schema.json +6 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +54 -11
- package/dist/skills/floless-app-steel-model/references/detail-from-a-screenshot.md +9 -5
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +128 -15
- package/dist/skills/floless-app-vectorize/SKILL.md +7 -4
- package/dist/templates/check-drawings.flo +46 -0
- package/dist/templates/drawing-check.flo +55 -0
- package/dist/templates/tekla-parser.flo +6 -2
- package/dist/web/app.css +143 -8
- package/dist/web/aware.js +512 -42
- package/dist/web/chat.css +171 -9
- package/dist/web/chat.js +2005 -759
- package/dist/web/commands-drawing-check.js +53 -0
- package/dist/web/commands-shell.js +275 -3
- package/dist/web/commands-steel.js +1 -0
- package/dist/web/commands-tekla-parser.js +3 -0
- package/dist/web/commands.js +1 -1
- package/dist/web/connections.js +382 -0
- package/dist/web/display-units.js +15 -1
- package/dist/web/drawing-check-editor.html +289 -0
- package/dist/web/drawing-check-editor.js +1242 -0
- package/dist/web/drawing-check-overlay.js +36 -0
- package/dist/web/filter-ai-proposal.js +32 -13
- package/dist/web/index.html +25 -3
- package/dist/web/instructor.js +2 -2
- package/dist/web/local-discovery.js +144 -2
- package/dist/web/model-display-units.js +23 -9
- package/dist/web/model-viewport-revit-adapter.js +12 -2
- package/dist/web/revit-editor.css +5 -0
- package/dist/web/revit-editor.js +141 -21
- package/dist/web/steel-editor.html +166 -27
- package/dist/web/steel-filter.html +60 -166
- package/dist/web/steel-model-v2-commands.js +13 -3
- package/dist/web/steel-model-v2-projection.js +20 -0
- package/dist/web/steel-units.js +3 -1
- package/dist/web/workspaces.js +323 -26
- package/distribution-resource-inventory.mjs +8 -1
- package/launch.mjs +5 -5
- package/package.json +3 -1
- package/dist/web/filter-ai-context.js +0 -92
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/* One generic "check it works" for anything connected (#1899, #1337 step 4).
|
|
2
|
+
*
|
|
3
|
+
* Shared by Discover, Integrations and Graft so a check looks and behaves the same everywhere. The
|
|
4
|
+
* browser decides nothing about safety: the server says what will run and whether the person must
|
|
5
|
+
* agree first; this file only shows that, asks, and renders the receipt AWARE produced.
|
|
6
|
+
* No vendor names here — what a check reads is described by the tool itself. */
|
|
7
|
+
(() => {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const make = (tag, className, content) => {
|
|
11
|
+
const node = document.createElement(tag);
|
|
12
|
+
if (className) node.className = className;
|
|
13
|
+
if (content != null) node.textContent = content;
|
|
14
|
+
return node;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** An error whose message is already a sentence for the person. Anything else is shown as a fixed one. */
|
|
18
|
+
class Plain extends Error {}
|
|
19
|
+
const FALLBACK = 'FloLess could not complete this. Try again, and if it keeps failing, report the problem from the menu.';
|
|
20
|
+
const sentenceOf = (error) => (error instanceof Plain ? error.message : FALLBACK);
|
|
21
|
+
|
|
22
|
+
async function call(path, options = {}) {
|
|
23
|
+
let response;
|
|
24
|
+
try {
|
|
25
|
+
response = await fetch(path, {
|
|
26
|
+
method: options.method || 'GET',
|
|
27
|
+
headers: options.body ? { 'Content-Type': 'application/json' } : undefined,
|
|
28
|
+
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
throw new Plain('FloLess could not reach its local service. Check that FloLess is open, then try again.');
|
|
32
|
+
}
|
|
33
|
+
const data = await response.json().catch(() => null);
|
|
34
|
+
// A server crash's text is never shown: only these routes' own replies (ok:false + a sentence,
|
|
35
|
+
// under 500) carry words meant for the person.
|
|
36
|
+
if (response.status >= 500 || !data || typeof data !== 'object') {
|
|
37
|
+
throw new Plain(response.status === 503
|
|
38
|
+
? 'FloLess is still getting ready. Wait a moment, then try again.'
|
|
39
|
+
: FALLBACK);
|
|
40
|
+
}
|
|
41
|
+
if (response.status === 409 && data.code === 'busy') throw new Plain(data.error);
|
|
42
|
+
if (!response.ok && typeof data.error !== 'string') {
|
|
43
|
+
throw new Plain(response.status === 409 ? 'FloLess is still getting ready. Wait a moment, then try again.' : FALLBACK);
|
|
44
|
+
}
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const receiptKey = (agent, alias) => `${agent}\u0000${alias || ''}`;
|
|
49
|
+
let receiptCache = new Map();
|
|
50
|
+
|
|
51
|
+
async function loadReceipts() {
|
|
52
|
+
const data = await call('/api/connections/receipts');
|
|
53
|
+
receiptCache = new Map((data.receipts || []).map((r) => [receiptKey(r.agent, r.alias), r]));
|
|
54
|
+
return receiptCache;
|
|
55
|
+
}
|
|
56
|
+
const cachedReceipt = (agent, alias) => receiptCache.get(receiptKey(agent, alias)) || null;
|
|
57
|
+
|
|
58
|
+
function relativeTime(iso) {
|
|
59
|
+
const ms = Date.parse(iso);
|
|
60
|
+
if (Number.isNaN(ms)) return '';
|
|
61
|
+
const minutes = Math.round((Date.now() - ms) / 60000);
|
|
62
|
+
if (minutes < 1) return 'just now';
|
|
63
|
+
if (minutes < 60) return `${minutes} min ago`;
|
|
64
|
+
const hours = Math.round(minutes / 60);
|
|
65
|
+
if (hours < 24) return `${hours} h ago`;
|
|
66
|
+
return new Date(ms).toLocaleDateString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The chip a receipt earns: label + the existing is-chat-* state class. */
|
|
70
|
+
function receiptChip(receipt) {
|
|
71
|
+
if (!receipt) return null;
|
|
72
|
+
if (receipt.state === 'failed' || !receipt.ok) return { label: 'Couldn’t confirm', cls: 'is-chat-unavailable' };
|
|
73
|
+
if (receipt.state === 'stale') return { label: 'Check again', cls: 'is-chat-warning' };
|
|
74
|
+
if (!receipt.reviewed) return { label: 'Checked, not reviewed', cls: 'is-chat-warning' };
|
|
75
|
+
return { label: 'Verified', cls: 'is-chat-ready' };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A failure that produced no receipt (nothing ran): its sentence, in the card, as its own row. */
|
|
79
|
+
function blockedNode(sentence) {
|
|
80
|
+
const row = make('div', 'int-account conn-receipt-row conn-blocked is-chat-unavailable');
|
|
81
|
+
const copy = make('div', 'int-account-copy');
|
|
82
|
+
copy.append(make('span', 'int-account-name', sentence));
|
|
83
|
+
row.append(copy);
|
|
84
|
+
return row;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** One receipt, rendered the same in every surface. */
|
|
88
|
+
function receiptNode(receipt, failureSentence) {
|
|
89
|
+
const wrap = make('div', 'conn-receipt');
|
|
90
|
+
if (!receipt) return wrap;
|
|
91
|
+
const chip = receiptChip(receipt);
|
|
92
|
+
const row = make('div', `int-account conn-receipt-row ${chip.cls}`);
|
|
93
|
+
const copy = make('div', 'int-account-copy');
|
|
94
|
+
const what = receipt.describe || 'Connection check';
|
|
95
|
+
copy.append(make('span', 'int-account-name', what));
|
|
96
|
+
const r = receipt.reported || {};
|
|
97
|
+
let line;
|
|
98
|
+
if (!receipt.ok) {
|
|
99
|
+
line = failureSentence || (typeof receipt.failureMessage === 'string' && receipt.failureMessage) || 'The connection check did not succeed. Try again.';
|
|
100
|
+
} else {
|
|
101
|
+
const parts = [];
|
|
102
|
+
// An account check usually reads the account itself, so what it read IS who answered.
|
|
103
|
+
if (r.summary && r.identity && r.summary === r.identity) parts.push(`Answered as ${r.identity}`);
|
|
104
|
+
else {
|
|
105
|
+
const read = r.summary ? `Read ${r.summary}` : 'Answered';
|
|
106
|
+
parts.push(r.identity ? `${read} from ${r.identity}` : read);
|
|
107
|
+
}
|
|
108
|
+
if (r.hostVersion) parts.push(r.hostVersion);
|
|
109
|
+
line = parts.join(' · ');
|
|
110
|
+
}
|
|
111
|
+
copy.append(make('span', 'int-account-origin', line));
|
|
112
|
+
const state = make('span', 'int-chat-state', chip.label);
|
|
113
|
+
const when = receipt.probedAt ? relativeTime(receipt.probedAt) : '';
|
|
114
|
+
if (when) {
|
|
115
|
+
state.textContent = `${chip.label} · ${when}`;
|
|
116
|
+
state.dataset.tip = `Checked ${new Date(receipt.probedAt).toLocaleString()}`;
|
|
117
|
+
}
|
|
118
|
+
row.append(copy, state);
|
|
119
|
+
let why = null;
|
|
120
|
+
if (receipt.ok && receipt.state === 'stale') {
|
|
121
|
+
why = receipt.staleBecause === 'key-changed'
|
|
122
|
+
? 'This account’s key changed after this check. Check again to confirm it still works.'
|
|
123
|
+
: receipt.staleBecause === 'key-unknown'
|
|
124
|
+
? 'FloLess can’t tell which key this account uses now. Reconnect it, then check again.'
|
|
125
|
+
: 'Checked before the tool was updated. Check again.';
|
|
126
|
+
} else if (receipt.ok && !receipt.reviewed) {
|
|
127
|
+
why = 'FloLess ran this command but could not confirm it only reads.';
|
|
128
|
+
}
|
|
129
|
+
if (why) row.append(make('span', 'int-account-reason', why));
|
|
130
|
+
wrap.append(row);
|
|
131
|
+
if (receipt.ok && receipt.previousIdentity && r.identity) {
|
|
132
|
+
const changed = make('div', 'int-account conn-receipt-row is-chat-warning');
|
|
133
|
+
const c = make('div', 'int-account-copy');
|
|
134
|
+
c.append(make('span', 'int-account-name', `This account is now ${r.identity}. Before it was ${receipt.previousIdentity}.`));
|
|
135
|
+
c.append(make('span', 'int-account-origin', 'Check this is the account you want FloLess to use.'));
|
|
136
|
+
changed.append(c);
|
|
137
|
+
wrap.append(changed);
|
|
138
|
+
}
|
|
139
|
+
return wrap;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** An inline "are you sure" row under the actions. Resolves true on Run, false on Cancel/Escape. */
|
|
143
|
+
function confirmInline(host, opener, check) {
|
|
144
|
+
return new Promise((resolve) => {
|
|
145
|
+
const id = `conn-confirm-${Math.random().toString(36).slice(2)}`;
|
|
146
|
+
const row = make('div', 'int-account is-chat-warning conn-confirm');
|
|
147
|
+
row.setAttribute('role', 'alertdialog');
|
|
148
|
+
row.setAttribute('aria-labelledby', id);
|
|
149
|
+
const copy = make('div', 'int-account-copy');
|
|
150
|
+
const question = make('span', 'int-account-name');
|
|
151
|
+
question.id = id;
|
|
152
|
+
const sendsKey = !!check.origin;
|
|
153
|
+
if (sendsKey) {
|
|
154
|
+
question.append(`Your ${check.credentialHandle} key will be sent to `, make('code', 'conn-code', check.origin), '.');
|
|
155
|
+
copy.append(question, make('span', 'int-account-origin', 'Only continue if you trust that address.'));
|
|
156
|
+
} else {
|
|
157
|
+
question.append('FloLess can’t tell that this command only reads. Run ', make('code', 'conn-code', check.command), ' anyway?');
|
|
158
|
+
copy.append(question, make('span', 'int-account-origin', check.describe || 'This tool did not describe what its check does.'));
|
|
159
|
+
}
|
|
160
|
+
if (sendsKey && !check.reviewed) {
|
|
161
|
+
copy.append(make('span', 'int-account-origin', `FloLess also can’t tell that ${check.command} only reads.`));
|
|
162
|
+
}
|
|
163
|
+
const actions = make('div', 'conn-confirm-actions');
|
|
164
|
+
const run = make('button', 'int-action', sendsKey ? 'Send key and check' : 'Run it');
|
|
165
|
+
run.type = 'button'; run.dataset.commandId = 'shell.connection-confirm-run';
|
|
166
|
+
const cancel = make('button', 'int-action', 'Cancel');
|
|
167
|
+
cancel.type = 'button'; cancel.dataset.commandId = 'shell.connection-confirm-cancel';
|
|
168
|
+
actions.append(run, cancel);
|
|
169
|
+
row.append(copy, actions);
|
|
170
|
+
host.replaceChildren(row);
|
|
171
|
+
opener.setAttribute('aria-expanded', 'true');
|
|
172
|
+
const finish = (answer) => {
|
|
173
|
+
row.removeEventListener('keydown', onKey, true);
|
|
174
|
+
host.replaceChildren();
|
|
175
|
+
opener.setAttribute('aria-expanded', 'false');
|
|
176
|
+
if (!answer) opener.focus();
|
|
177
|
+
resolve(answer);
|
|
178
|
+
};
|
|
179
|
+
const onKey = (event) => {
|
|
180
|
+
if (event.key !== 'Escape') return;
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
event.stopPropagation(); // Escape closes this question, not the window behind it
|
|
183
|
+
finish(false);
|
|
184
|
+
};
|
|
185
|
+
row.addEventListener('keydown', onKey, true);
|
|
186
|
+
run.addEventListener('click', () => finish(true));
|
|
187
|
+
cancel.addEventListener('click', () => finish(false));
|
|
188
|
+
cancel.focus();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A "Check it works" button for (agent, alias). `receiptHost` shows the receipt, `confirmHost`
|
|
194
|
+
* holds the inline confirmation, `announce(text)` reports the outcome to a polite live region.
|
|
195
|
+
*/
|
|
196
|
+
function checkButton({ agent, alias = null, label, receiptHost, confirmHost, announce, onReceipt }) {
|
|
197
|
+
const button = make('button', 'int-action conn-check', 'Check it works');
|
|
198
|
+
button.type = 'button';
|
|
199
|
+
button.dataset.commandId = `shell.connection-check#${agent}${alias ? `.${alias}` : ''}`;
|
|
200
|
+
button.dataset.commandInstanceLabel = label || agent;
|
|
201
|
+
button.setAttribute('aria-label', `Check that ${label || agent} works`);
|
|
202
|
+
button.setAttribute('aria-expanded', 'false');
|
|
203
|
+
const say = (text) => { if (typeof announce === 'function') announce(text); };
|
|
204
|
+
button.addEventListener('click', async () => {
|
|
205
|
+
if (button.getAttribute('aria-busy') === 'true') return;
|
|
206
|
+
const setBusy = (busy) => {
|
|
207
|
+
button.setAttribute('aria-busy', String(busy));
|
|
208
|
+
button.disabled = busy;
|
|
209
|
+
button.textContent = busy ? 'Checking…' : 'Check it works';
|
|
210
|
+
};
|
|
211
|
+
setBusy(true);
|
|
212
|
+
try {
|
|
213
|
+
// A check that could not start keeps the last receipt and adds why, in the card itself.
|
|
214
|
+
const blocked = (sentence) => {
|
|
215
|
+
receiptHost?.querySelector('.conn-blocked')?.remove();
|
|
216
|
+
receiptHost?.prepend(blockedNode(sentence));
|
|
217
|
+
say(sentence);
|
|
218
|
+
};
|
|
219
|
+
const prepared = await call(`/api/connections/${encodeURIComponent(agent)}/probe/prepare`, { method: 'POST', body: { alias } });
|
|
220
|
+
if (!prepared.ok) { blocked(prepared.error || 'FloLess could not prepare this check. Try again.'); return; }
|
|
221
|
+
if (!prepared.available) { blocked(prepared.message); return; }
|
|
222
|
+
// This check can start, so an earlier attempt's reason it couldn't is no longer true.
|
|
223
|
+
receiptHost?.querySelector('.conn-blocked')?.remove();
|
|
224
|
+
let confirmToken = null;
|
|
225
|
+
if (prepared.confirmToken) {
|
|
226
|
+
setBusy(false);
|
|
227
|
+
const agreed = confirmHost ? await confirmInline(confirmHost, button, prepared.check) : false;
|
|
228
|
+
if (!agreed) { say('Check cancelled. Nothing was run.'); return; }
|
|
229
|
+
confirmToken = prepared.confirmToken;
|
|
230
|
+
setBusy(true);
|
|
231
|
+
}
|
|
232
|
+
const result = await call(`/api/connections/${encodeURIComponent(agent)}/probe`, { method: 'POST', body: { alias, confirmToken } });
|
|
233
|
+
const receipt = result.receipt || null;
|
|
234
|
+
if (!receipt) { blocked(result.error || 'The check did not succeed. Try again.'); return; }
|
|
235
|
+
receiptCache.set(receiptKey(agent, alias), receipt);
|
|
236
|
+
if (receiptHost) receiptHost.replaceChildren(receiptNode(receipt, result.ok ? null : result.error));
|
|
237
|
+
say(result.ok ? `Checked ${label || agent}. ${receiptChip(receipt).label}.` : (result.error || 'The check did not succeed.'));
|
|
238
|
+
if (typeof onReceipt === 'function') onReceipt(receipt);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
say(sentenceOf(error));
|
|
241
|
+
} finally {
|
|
242
|
+
setBusy(false);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return button;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async function loadServices() {
|
|
249
|
+
const data = await call('/api/connections/services');
|
|
250
|
+
if (!data.ok) throw new Plain(data.error || 'FloLess couldn’t load the list of services. Close this window and try again.');
|
|
251
|
+
const services = data.services || [];
|
|
252
|
+
if (data.choicesUnreadable) services.choicesUnreadable = true;
|
|
253
|
+
return services;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The account a service's check should use, or undefined when it cannot be named without guessing:
|
|
258
|
+
* the chosen FloLess account, else the only connected one. Never "the default" by assumption.
|
|
259
|
+
*/
|
|
260
|
+
/** A sign-in service whose every account has expired: it has accounts, but none FloLess can use. */
|
|
261
|
+
function signInExpired(service) {
|
|
262
|
+
return service?.kind === 'sign-in' && !service.connected
|
|
263
|
+
&& (service.accounts || []).some((account) => account.status === 'expired');
|
|
264
|
+
}
|
|
265
|
+
const EXPIRED_SENTENCE = 'Its sign-in expired. Reconnect it, then check it works.';
|
|
266
|
+
|
|
267
|
+
function checkAccountOf(service) {
|
|
268
|
+
if (service.choice?.source === 'floless') return service.choice.alias ?? null;
|
|
269
|
+
const usable = (service.accounts || []).filter((a) => a.status === 'valid' || a.status === 'present');
|
|
270
|
+
return usable.length === 1 ? (usable[0].alias ?? null) : undefined;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* "Account FloLess uses" for one service row. Saves on change; on failure says so and reverts.
|
|
275
|
+
* A key service has no Claude/Codex connection to offer.
|
|
276
|
+
*/
|
|
277
|
+
function accountChoiceNode(service, { announce, onSaved } = {}) {
|
|
278
|
+
const fieldset = make('fieldset', 'conn-choice');
|
|
279
|
+
fieldset.append(make('legend', 'int-accounts-label', 'ACCOUNT FLOLESS USES'));
|
|
280
|
+
const name = `conn-choice-${service.id}`;
|
|
281
|
+
let choice = service.choice || { source: null, alias: null, revision: 0 };
|
|
282
|
+
const usable = (service.accounts || []).filter((a) => a.status === 'valid' || a.status === 'present');
|
|
283
|
+
const options = [];
|
|
284
|
+
for (const account of usable) {
|
|
285
|
+
options.push({
|
|
286
|
+
value: `floless:${account.alias || ''}`, source: 'floless', alias: account.alias || null,
|
|
287
|
+
title: account.alias ? `FloLess account · ${account.alias}` : 'Default FloLess account',
|
|
288
|
+
note: 'FloLess uses exactly this account and never switches to another one.',
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (service.kind === 'sign-in') {
|
|
292
|
+
options.push({ value: 'native', source: 'native', alias: null, title: 'Your Claude or Codex connection',
|
|
293
|
+
note: 'FloLess can’t see which account this uses, so it can’t check it.' });
|
|
294
|
+
}
|
|
295
|
+
options.push({ value: 'none', source: null, alias: null, title: 'Not chosen', note: 'AI Chat will ask you when it needs one.' });
|
|
296
|
+
const current = () => (choice.source === 'floless' ? `floless:${choice.alias || ''}` : choice.source === 'native' ? 'native' : 'none');
|
|
297
|
+
let lost = choice.source === 'floless' && !options.some((o) => o.value === current());
|
|
298
|
+
for (const option of options) {
|
|
299
|
+
const label = make('label', 'conn-choice-option');
|
|
300
|
+
const input = document.createElement('input');
|
|
301
|
+
input.type = 'radio'; input.name = name; input.value = option.value;
|
|
302
|
+
input.setAttribute('aria-label', option.title);
|
|
303
|
+
input.dataset.commandId = `shell.integrations-account-choice#${service.id}`;
|
|
304
|
+
input.dataset.commandInstanceLabel = `${service.name}: ${option.title}`;
|
|
305
|
+
input.checked = lost ? option.value === 'none' : option.value === current();
|
|
306
|
+
const text = make('span', 'conn-choice-text');
|
|
307
|
+
text.append(make('span', 'int-account-name', option.title), make('span', 'int-account-origin', option.note));
|
|
308
|
+
label.append(input, text);
|
|
309
|
+
fieldset.append(label);
|
|
310
|
+
input.addEventListener('change', async () => {
|
|
311
|
+
if (!input.checked) return;
|
|
312
|
+
try {
|
|
313
|
+
const data = await call(`/api/integrations/${encodeURIComponent(service.id)}/account-choice`, {
|
|
314
|
+
method: 'PUT', body: { source: option.source, alias: option.alias, expectedRevision: choice.revision },
|
|
315
|
+
});
|
|
316
|
+
if (!data.ok) {
|
|
317
|
+
// Another window changed it: take the stored choice, and let the card follow it too.
|
|
318
|
+
if (data.choice) { choice = data.choice; if (typeof onSaved === 'function') onSaved(choice); }
|
|
319
|
+
throw new Plain(data.error || 'FloLess couldn’t save this choice. Try again.');
|
|
320
|
+
}
|
|
321
|
+
choice = data.choice;
|
|
322
|
+
lost = false;
|
|
323
|
+
fieldset.querySelector('.conn-choice-lost')?.remove();
|
|
324
|
+
if (typeof announce === 'function') announce('Account choice saved.');
|
|
325
|
+
if (typeof onSaved === 'function') onSaved(choice);
|
|
326
|
+
} catch (error) {
|
|
327
|
+
// Show what is really stored (the server's current choice when it sent one), never the click.
|
|
328
|
+
for (const radio of fieldset.querySelectorAll('input[type="radio"]')) radio.checked = radio.value === current();
|
|
329
|
+
if (typeof announce === 'function') announce(sentenceOf(error));
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
if (lost) {
|
|
334
|
+
const warn = make('div', 'int-account is-chat-warning conn-choice-lost');
|
|
335
|
+
warn.append(make('span', 'int-account-name', 'The account you chose is no longer connected. Choose another.'));
|
|
336
|
+
fieldset.append(warn);
|
|
337
|
+
}
|
|
338
|
+
return fieldset;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Everything one service shows under "Account FloLess uses": the choice, its Check it works buttons
|
|
343
|
+
* (for the account that choice names, never a guessed one), and where results and refusals appear.
|
|
344
|
+
*/
|
|
345
|
+
function serviceConnectionNode(service) {
|
|
346
|
+
const wrap = make('div', 'conn-service');
|
|
347
|
+
const receiptHost = make('div', 'conn-receipt-host');
|
|
348
|
+
receiptHost.setAttribute('role', 'status');
|
|
349
|
+
const confirmHost = make('div', 'conn-confirm-host');
|
|
350
|
+
const actions = make('div', 'conn-confirm-actions');
|
|
351
|
+
const note = make('div', 'int-account-empty');
|
|
352
|
+
// Visible, per card: an account-choice or check outcome is a sentence the person must read.
|
|
353
|
+
const said = make('div', 'int-account-empty conn-said');
|
|
354
|
+
said.setAttribute('role', 'status');
|
|
355
|
+
const say = (text) => { said.textContent = text; };
|
|
356
|
+
const paintChecks = (choice) => {
|
|
357
|
+
actions.replaceChildren(); note.textContent = '';
|
|
358
|
+
const checks = Array.isArray(service.checks) ? service.checks : [];
|
|
359
|
+
if (!checks.length) return;
|
|
360
|
+
if (choice?.source === 'native') { note.textContent = 'FloLess can’t check an account it can’t see.'; return; }
|
|
361
|
+
if (service.statusUnknown) { note.textContent = 'FloLess couldn’t read whether this key is saved. Close this window and try again.'; return; }
|
|
362
|
+
if (signInExpired(service)) { note.textContent = EXPIRED_SENTENCE; return; }
|
|
363
|
+
if (!service.connected) { note.textContent = service.kind === 'key' ? 'Save the key first, then check it works.' : 'Connect first, then check it works.'; return; }
|
|
364
|
+
const alias = checkAccountOf({ ...service, choice });
|
|
365
|
+
if (alias === undefined) { note.textContent = 'Choose the account FloLess uses above, then check it works.'; return; }
|
|
366
|
+
for (const check of checks) {
|
|
367
|
+
const label = check.name === service.name ? service.name : `${service.name} (${check.name})`;
|
|
368
|
+
actions.append(checkButton({ agent: check.id, alias, label, receiptHost, confirmHost, announce: say }));
|
|
369
|
+
const latest = cachedReceipt(check.id, alias);
|
|
370
|
+
if (latest) receiptHost.replaceChildren(receiptNode(latest));
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
wrap.append(accountChoiceNode(service, { announce: say, onSaved: paintChecks }), actions, note, confirmHost, receiptHost, said);
|
|
374
|
+
paintChecks(service.choice);
|
|
375
|
+
return wrap;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
window.flolessConnections = {
|
|
379
|
+
loadReceipts, cachedReceipt, receiptNode, receiptChip, checkButton, loadServices, accountChoiceNode, checkAccountOf, sentenceOf,
|
|
380
|
+
serviceConnectionNode, signInExpired, EXPIRED_SENTENCE,
|
|
381
|
+
};
|
|
382
|
+
})();
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* makes "no pixel moved" a checkable claim rather than a hope.
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
|
-
import { FT_TO_MM, IN_TO_MM } from './steel-units.js';
|
|
40
|
+
import { FT_TO_MM, IN_TO_MM, LB_TO_KG } from './steel-units.js';
|
|
41
41
|
|
|
42
42
|
/** Feet and inches, to the nearest sixteenth — the US/AISC drawing convention. */
|
|
43
43
|
export const FT_IN = 'ft-in';
|
|
@@ -60,6 +60,20 @@ export function normalizeDisplayUnits(value) {
|
|
|
60
60
|
return value === MM ? MM : FT_IN;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A recorded weight, in kilograms, as the number the chosen system shows: pounds for `ft-in`,
|
|
65
|
+
* kilograms for `mm`. RAW — rounding is the caller's display step. Records stay kilograms; this is
|
|
66
|
+
* the one place a chat receipt or a chat answer turns them into pounds (#1798).
|
|
67
|
+
*/
|
|
68
|
+
export function weightIn(kg, units) {
|
|
69
|
+
return normalizeDisplayUnits(units) === MM ? kg : kg / LB_TO_KG;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The word a weight in that system is written with: "lb" or "kg". */
|
|
73
|
+
export function weightUnitWord(units) {
|
|
74
|
+
return normalizeDisplayUnits(units) === MM ? 'kg' : 'lb';
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
/** Absent / unreadable numbers render as nothing, which is what `fmtFtIn` always did. */
|
|
64
78
|
const blank = (mm) => mm == null || typeof mm === 'boolean' || !Number.isFinite(Number(mm));
|
|
65
79
|
|