@floless/app 0.104.2 → 0.106.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 +11505 -8050
- package/dist/schemas/steel.model.v2.schema.json +652 -0
- package/dist/schemas/steel.takeoff.v1.schema.json +54 -4
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +109 -5
- package/dist/skills/floless-app-tweak-contract/SKILL.md +23 -7
- package/dist/skills/floless-app-vectorize/SKILL.md +21 -5
- package/dist/templates/steel-model.flo +5 -1
- package/dist/templates/vectorize.flo +5 -1
- package/dist/web/app.css +119 -4
- package/dist/web/aware.js +526 -65
- package/dist/web/index.html +28 -1
- package/dist/web/steel-3d-core.js +242 -0
- package/dist/web/steel-3d-view.js +515 -50
- package/dist/web/steel-editor.html +1508 -175
- package/dist/web/steel-filter.html +67 -2
- package/dist/web/steel-materials.js +249 -0
- package/dist/web/steel-model-adapter.js +210 -0
- package/dist/web/steel-model-commands.js +691 -0
- package/dist/web/steel-view-generation.js +10 -1
- package/dist/web/vector-editor.html +118 -3
- package/dist/web/vendor/README.md +6 -1
- package/dist/web/vendor/RoomEnvironment.js +185 -0
- package/dist/web/workspaces.js +509 -79
- package/package.json +6 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -168,6 +168,9 @@
|
|
|
168
168
|
{ kind: 'bom-xlsx', ico: '▦', name: 'Bill of materials', fmt: 'XLSX', verb: 'Export Excel', file: true, open: true },
|
|
169
169
|
{ kind: 'ifc', ico: '◈', name: 'Model', fmt: 'IFC4', verb: 'Export IFC', file: true, open: false },
|
|
170
170
|
{ kind: 'tekla', ico: '◧', name: 'Tekla', fmt: 'Native parts', verb: 'Send to Tekla', file: false },
|
|
171
|
+
// Yields a URL, not a file, so none of the exportState/receipt plumbing applies — its status
|
|
172
|
+
// comes from shareCardState and its result is a link with a Copy button (see cardHtml).
|
|
173
|
+
{ kind: 'share-3d', ico: '↗', name: 'Model', fmt: 'Shareable web link', verb: 'Create share link', file: false },
|
|
171
174
|
],
|
|
172
175
|
},
|
|
173
176
|
vectorize: {
|
|
@@ -198,17 +201,58 @@
|
|
|
198
201
|
],
|
|
199
202
|
},
|
|
200
203
|
};
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
// A project names its app by the LIVE id, which a rename or a duplicate moves off the descriptor
|
|
205
|
+
// keys above — so resolve through the lineage ROOT the server ships beside it (`templateId`, derived
|
|
206
|
+
// from the app-origin store, which rename and duplicate both carry). A renamed steel-model still
|
|
207
|
+
// finds the steel descriptor, so its projects still open and still say "Steel model".
|
|
208
|
+
// • falls back to `app` for a server that predates the field, and because for a canonical app the
|
|
209
|
+
// two are the same string anyway;
|
|
210
|
+
// • `p.app` remains the LIVE id everywhere it addresses the server — the frames' ?app=, the export
|
|
211
|
+
// and approve routes — so this is a presentation resolution only, never a re-pointing.
|
|
212
|
+
const wsDescOf = (p) => (p && WORKSPACE_APPS[p.templateId || p.app]) || null;
|
|
213
|
+
const wsApp = () => wsDescOf(current);
|
|
214
|
+
/** A project's app in HUMAN words ("Steel model"), falling back to the raw id for an app we have
|
|
215
|
+
* no descriptor for — the only case that still reads as a slug, and it is one we can't name. */
|
|
216
|
+
const projectAppName = (p) => (wsDescOf(p) || {}).displayName || (p && p.app) || '';
|
|
217
|
+
/** The same, by DESCRIPTOR KEY — for the create cards, which name an app we have a descriptor for. */
|
|
218
|
+
const descDisplayName = (templateId) => (WORKSPACE_APPS[templateId] || {}).displayName || templateId;
|
|
219
|
+
/** Whether this project's app has been renamed or duplicated away from its built-in id. The only
|
|
220
|
+
* case where naming the live workflow on the card tells the user something they don't know. */
|
|
221
|
+
const wsRenamed = (p) => !!(p && p.templateId && p.app && p.app !== p.templateId);
|
|
203
222
|
let mode = 'workflows';
|
|
204
223
|
try { if (localStorage.getItem(LS_MODE) === 'workspaces') mode = 'workspaces'; } catch { /* private mode */ }
|
|
205
224
|
let projects = [];
|
|
225
|
+
let projectsLoadError = null; // last /api/projects failure reason, or null — an empty list means
|
|
226
|
+
// "none yet" ONLY when this is null (see the empty state in renderLanding)
|
|
206
227
|
let archived = []; // archived projects (the "Trash") — listed under a collapsed section on the landing
|
|
207
|
-
// Installed workspace apps, in descriptor order
|
|
208
|
-
// the set = apps flagged workspace===true
|
|
209
|
-
//
|
|
228
|
+
// Installed workspace apps, in descriptor order — `{ appId, templateId, ambiguous }` per entry.
|
|
229
|
+
// Populated from /api/apps in loadProjects(): the set = apps flagged workspace===true whose LINEAGE
|
|
230
|
+
// ROOT has a WORKSPACE_APPS descriptor (an app whose root we have no descriptor for is skipped with
|
|
231
|
+
// a console note — never a broken open).
|
|
232
|
+
//
|
|
233
|
+
// Two ids, because a rename separates them and each half is load-bearing: `appId` is the LIVE app a
|
|
234
|
+
// card creates on (post the descriptor key after a rename and the server rightly 404s "not
|
|
235
|
+
// installed"), `templateId` is the descriptor key supplying the card's copy. ONE entry per
|
|
236
|
+
// descriptor, preferring the canonical install: steel declares two create actions, so an entry per
|
|
237
|
+
// installed app would double the landing's most important surface the moment anyone duplicates a
|
|
238
|
+
// workflow. `ambiguous` marks a root with more than one live app behind it, so that single card can
|
|
239
|
+
// say which workflow it will use rather than silently picking (see renderLanding).
|
|
240
|
+
//
|
|
210
241
|
// Drives the per-app create cards. Falls back to the descriptor keys if /api/apps can't be read.
|
|
211
|
-
|
|
242
|
+
// Starts at the descriptor keys so the create cards are on the FIRST paint, then /api/apps narrows
|
|
243
|
+
// them. Two alternatives were tried and rejected against measurements:
|
|
244
|
+
// - starting EMPTY delayed the cards to 8-14 s (30-43 s loaded), leaving the landing visibly
|
|
245
|
+
// half-built with the empty state pointing at "the cards above" when nothing was above;
|
|
246
|
+
// - rendering them DISABLED until /api/apps confirmed left them dead for 18-60 s, because that
|
|
247
|
+
// call queues behind the (slow, uncached) /api/workflows/updates — a dead control is no better
|
|
248
|
+
// than a missing one.
|
|
249
|
+
// The hazard those were guarding — clicking a card for an app that isn't installed — is closed
|
|
250
|
+
// where it belongs instead: POST /api/projects refuses an app with no readable source, so no
|
|
251
|
+
// client's paint timing can mint an orphan project, and the click surfaces an honest error toast.
|
|
252
|
+
// The pre-/api/apps default (and the failure fallback): assume each descriptor's canonical app is
|
|
253
|
+
// the installed one. Unambiguous by construction — one entry per descriptor, appId === templateId.
|
|
254
|
+
const wsDefaultAppEntries = () => Object.keys(WORKSPACE_APPS).map((id) => ({ appId: id, templateId: id, ambiguous: false }));
|
|
255
|
+
let wsAppEntries = wsDefaultAppEntries();
|
|
212
256
|
let current = null; // the open project (null = landing)
|
|
213
257
|
|
|
214
258
|
// The open app's visible label for a step key (Model→"Model" for steel, "Traced" for vectorize) —
|
|
@@ -231,7 +275,7 @@
|
|
|
231
275
|
// `exported` = an SVG export file exists (from the last export listing); best-known from
|
|
232
276
|
// exportState, which renderExports() populates. Unknown before Exports is opened → false.
|
|
233
277
|
const exported = !!(exportState && exportState.svg && exportState.svg.exportedAt);
|
|
234
|
-
bridge.setWorkspaceGuide({ app: current.app, name: current.name, displayName:
|
|
278
|
+
bridge.setWorkspaceGuide({ app: current.app, name: current.name, displayName: projectAppName(current), approved: !!current.approvedAt, exported });
|
|
235
279
|
}
|
|
236
280
|
|
|
237
281
|
// ── mode ────────────────────────────────────────────────────────────────────
|
|
@@ -287,36 +331,165 @@
|
|
|
287
331
|
return h < 48 ? `${h} h ago` : `${Math.round(h / 24)} d ago`;
|
|
288
332
|
};
|
|
289
333
|
|
|
290
|
-
|
|
334
|
+
// Monotonic id per load. applyMode() fires loadProjects() fire-and-forget and re-runs on any mode
|
|
335
|
+
// set (even a no-op one), and several actions trail a refresh, so two loads can overlap. Without
|
|
336
|
+
// this, a slow FAILING load that started first can land after a fast successful one and repaint
|
|
337
|
+
// the error over a list that is actually fine (or the reverse, erasing a real failure). Only the
|
|
338
|
+
// newest load may touch shared state or paint. Same discipline as the editor's saveSeq.
|
|
339
|
+
let projectsLoadSeq = 0;
|
|
340
|
+
|
|
341
|
+
// `quiet` suppresses the failure toast: the retry button's own pending state and the banner it sits
|
|
342
|
+
// in already report the outcome, and a retry against a cached 402 completes in ~35 ms, so the
|
|
343
|
+
// re-entrancy guard never gets to fire and five clicks produced five identical toasts.
|
|
344
|
+
async function loadProjects(opts) {
|
|
345
|
+
const seq = ++projectsLoadSeq;
|
|
346
|
+
const stale = () => seq !== projectsLoadSeq;
|
|
291
347
|
// Surface a real failure — never present a server/network error as an empty workspace
|
|
292
348
|
// (the empty-state CTA would be a lie: "no projects yet" when the truth is "load failed").
|
|
293
|
-
try {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
349
|
+
try {
|
|
350
|
+
const res = await api('/api/projects');
|
|
351
|
+
if (stale()) return;
|
|
352
|
+
projects = res.projects;
|
|
353
|
+
projectsLoadError = null;
|
|
354
|
+
} catch (err) {
|
|
355
|
+
if (stale()) return;
|
|
356
|
+
projects = [];
|
|
357
|
+
// Remember WHY, so renderLanding can say "couldn't load" instead of "none yet" (they look
|
|
358
|
+
// identical from `projects` alone). Cleared on the next success, so a recovered load drops
|
|
359
|
+
// straight back to the normal empty state.
|
|
360
|
+
projectsLoadError = (err && err.message) || String(err);
|
|
361
|
+
if (!(opts && opts.quiet)) showToast('Couldn’t load projects: ' + projectsLoadError, 'warn');
|
|
362
|
+
}
|
|
363
|
+
// Paint the moment the LIST is in hand — before the archived call, not after it. That call is a
|
|
364
|
+
// secondary concern (a collapsed Trash disclosure) but it was measured at 0.31-0.83 s normally
|
|
365
|
+
// and 5.6 s under load, and holding the first paint behind it made it the only remaining source
|
|
366
|
+
// of a blank landing. The repaint below adds the Archived section when it arrives.
|
|
367
|
+
renderLanding();
|
|
368
|
+
// Archived ("Trash") list — never let its failure blank the main workspace, but don't swallow it
|
|
369
|
+
// silently either: warn so a broken archive listing is diagnosable (a bare catch here would hide
|
|
370
|
+
// a real 500 and leave the "Archived" section invisible with no breadcrumb).
|
|
371
|
+
// Signature covers what the rows actually RENDER, not just which rows exist: another client can
|
|
372
|
+
// restore and re-archive the same project (same id, new updatedAt) or rename it, and an
|
|
373
|
+
// id-only comparison would skip the repaint and leave a stale name / "archived N days ago".
|
|
374
|
+
// JSON.stringify, not a delimiter join — names are user-supplied and unrestricted, so a name
|
|
375
|
+
// containing the delimiters could forge another row's signature and suppress a real repaint.
|
|
376
|
+
const archivedSig = (list) => JSON.stringify(list.map((p) => [p.id, p.name, p.app, p.updatedAt]));
|
|
377
|
+
const archivedBefore = archivedSig(archived);
|
|
378
|
+
try {
|
|
379
|
+
const res = await api('/api/projects/archived');
|
|
380
|
+
if (stale()) return;
|
|
381
|
+
archived = res.projects;
|
|
382
|
+
} catch (err) {
|
|
383
|
+
if (stale()) return;
|
|
384
|
+
archived = [];
|
|
385
|
+
console.warn('[workspaces] archived list failed to load: ' + (err && err.message || err));
|
|
386
|
+
}
|
|
387
|
+
if (archivedSig(archived) !== archivedBefore) renderLanding();
|
|
300
388
|
// Which workspace apps to offer a create card for: those flagged workspace===true on /api/apps
|
|
301
|
-
//
|
|
302
|
-
//
|
|
389
|
+
// whose LINEAGE ROOT we also know how to render (have a WORKSPACE_APPS descriptor). Matching on
|
|
390
|
+
// the root, not the raw id, is what keeps the cards alive across a rename — a renamed steel-model
|
|
391
|
+
// is still flagged workspace, but under a key no descriptor answers to. /api/apps already carries
|
|
392
|
+
// `templateId` per app (the picker's fork/update badges read the same field), so no extra call.
|
|
393
|
+
// Keep descriptor order for a stable card order. A load failure RE-WIDENS the entries to the
|
|
394
|
+
// descriptor keys (the catch assigns them): still usable, and a card for something uninstalled is
|
|
395
|
+
// refused by the server on click.
|
|
396
|
+
const cardsSig = (entries) => entries.map((e) => `${e.appId}>${e.templateId}${e.ambiguous ? '?' : ''}`).join(',');
|
|
397
|
+
const cardsBefore = cardsSig(wsAppEntries);
|
|
303
398
|
try {
|
|
304
399
|
const { apps } = await api('/api/apps');
|
|
305
|
-
|
|
306
|
-
|
|
400
|
+
if (stale()) return;
|
|
401
|
+
// Group the live workspace apps by lineage root, so one descriptor yields one card even when
|
|
402
|
+
// several installed apps share a root (an original plus a duplicate, say).
|
|
403
|
+
const byRoot = new Map();
|
|
404
|
+
for (const a of apps || []) {
|
|
405
|
+
if (!a || a.workspace !== true) continue;
|
|
406
|
+
const root = a.templateId || a.id;
|
|
407
|
+
if (!WORKSPACE_APPS[root]) {
|
|
408
|
+
console.warn(`[workspaces] app "${a.id}" is flagged workspace but its lineage root "${root}" has no client descriptor — skipping its create card`);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (!byRoot.has(root)) byRoot.set(root, []);
|
|
412
|
+
byRoot.get(root).push(a.id);
|
|
413
|
+
}
|
|
414
|
+
wsAppEntries = Object.keys(WORKSPACE_APPS).filter((root) => byRoot.has(root)).map((root) => {
|
|
415
|
+
// Sorted, so which app a card targets is stable across loads rather than dependent on the
|
|
416
|
+
// order `aware app list` happened to return. The canonical install wins when present: it is
|
|
417
|
+
// the one the user has not deliberately made a variant of.
|
|
418
|
+
const ids = byRoot.get(root).slice().sort();
|
|
419
|
+
return { appId: ids.indexOf(root) >= 0 ? root : ids[0], templateId: root, ambiguous: ids.length > 1 };
|
|
420
|
+
});
|
|
307
421
|
// Hardening: /api/apps loaded but flagged NONE of our known workspace apps (a transient
|
|
308
422
|
// appWorkspace read blip returning false for all). Rather than render zero create cards, fall
|
|
309
423
|
// back to the descriptor keys — the same usable default a full /api/apps failure lands on.
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
for (const a of apps || []) {
|
|
314
|
-
if (a && a.workspace === true && !WORKSPACE_APPS[a.id]) {
|
|
315
|
-
console.warn(`[workspaces] app "${a.id}" is flagged workspace but has no client descriptor — skipping its create card`);
|
|
316
|
-
}
|
|
424
|
+
if (wsAppEntries.length === 0 && Object.keys(WORKSPACE_APPS).length > 0) {
|
|
425
|
+
wsAppEntries = wsDefaultAppEntries();
|
|
317
426
|
}
|
|
318
|
-
} catch {
|
|
319
|
-
|
|
427
|
+
} catch {
|
|
428
|
+
if (stale()) return;
|
|
429
|
+
// /api/apps failed — fall back to the descriptor keys so the create cards still work.
|
|
430
|
+
wsAppEntries = wsDefaultAppEntries();
|
|
431
|
+
}
|
|
432
|
+
// Second paint ONLY if /api/apps actually changed the card set. It usually confirms what the
|
|
433
|
+
// previous answer already showed, and a blind repaint seconds later would blow away whatever the
|
|
434
|
+
// user has since touched in the landing — an open kebab menu, the expanded Archived section.
|
|
435
|
+
if (cardsSig(wsAppEntries) !== cardsBefore) {
|
|
436
|
+
// #ws-proj-menu lives outside $landing, so the rebuild below does NOT close it — it would stay
|
|
437
|
+
// pinned at the coordinates of the kebab that opened it while the grid reflows under it
|
|
438
|
+
// (dropping create cards shifts every project card up), leaving it beside a different project
|
|
439
|
+
// than the one it acts on. It targets by id so nothing acts on the wrong row, but it reads as
|
|
440
|
+
// if it does. Close it first.
|
|
441
|
+
closeProjMenu();
|
|
442
|
+
renderLanding();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Translate the failures we can recognise into the user's language, the way kbPaintError does for
|
|
447
|
+
// the Knowledge viewer. Returns '' for anything unrecognised — better to show only the raw detail
|
|
448
|
+
// than to guess wrong about why. The raw string is shown either way, just demoted.
|
|
449
|
+
function projectsErrorHint(reason) {
|
|
450
|
+
const r = String(reason || '').toLowerCase();
|
|
451
|
+
if (/subscription|session|sign in|402/.test(r)) return 'Your sign-in needs refreshing — sign in again, then retry.';
|
|
452
|
+
if (/failed to fetch|networkerror|load failed|econnrefused|connection/.test(r)) return 'The local server didn’t answer.';
|
|
453
|
+
if (/http 5\d\d/.test(r)) return 'The server hit an error listing them.';
|
|
454
|
+
return '';
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Retry from the error banner. renderLanding() replaces the button that was clicked, so focus
|
|
458
|
+
// would collapse to <body>; put it back where the user left it — the same discipline as
|
|
459
|
+
// restoreExportFocus() and wsOpenHistory()'s explicit refocus.
|
|
460
|
+
let retryInFlight = false;
|
|
461
|
+
async function retryProjects() {
|
|
462
|
+
// This panel appears exactly when the server is slow or wedged, so the retry can take many
|
|
463
|
+
// seconds. Without a pending state the UI is byte-identical after the click and the user clicks
|
|
464
|
+
// again (and again), each landing its own failure toast. Same shape as aware.js's bootstrap
|
|
465
|
+
// retry: guard re-entry, disable, and SAY it is trying.
|
|
466
|
+
if (retryInFlight) return;
|
|
467
|
+
const btn = document.getElementById('ws-retry-projects');
|
|
468
|
+
const hadFocus = document.activeElement === btn;
|
|
469
|
+
retryInFlight = true;
|
|
470
|
+
if (btn) { btn.disabled = true; btn.textContent = 'Trying…'; }
|
|
471
|
+
try {
|
|
472
|
+
await loadProjects({ quiet: true }); // the banner + this button already say what happened
|
|
473
|
+
} catch (err) {
|
|
474
|
+
// loadProjects swallows API failures itself, so reaching here means the RENDER threw. The
|
|
475
|
+
// repaint that would have replaced this button never happened, so restore it by hand —
|
|
476
|
+
// otherwise the one recovery control on screen stays disabled reading "Trying…" forever.
|
|
477
|
+
console.error('[workspaces] retry failed to render: ' + ((err && err.message) || err));
|
|
478
|
+
if (btn && btn.isConnected) { btn.disabled = false; btn.textContent = '↻ Try again'; }
|
|
479
|
+
} finally {
|
|
480
|
+
retryInFlight = false;
|
|
481
|
+
// If a concurrent load superseded this one, loadProjects bailed at its first await WITHOUT
|
|
482
|
+
// painting — so the repaint that would have replaced this button never happened and it would
|
|
483
|
+
// sit disabled reading "Trying…", dead, until some other load lands. That other load is
|
|
484
|
+
// against the same slow server this banner is complaining about. Restore it ourselves if it
|
|
485
|
+
// is still the live element.
|
|
486
|
+
const same = document.getElementById('ws-retry-projects');
|
|
487
|
+
if (same && same === btn && same.disabled) { same.disabled = false; same.textContent = '↻ Try again'; }
|
|
488
|
+
}
|
|
489
|
+
if (!hadFocus) return;
|
|
490
|
+
const again = document.getElementById('ws-retry-projects'); // still failing → the new button
|
|
491
|
+
const firstCard = $landing.querySelector('.ws-card[data-open]'); // recovered → the list it just loaded
|
|
492
|
+
(again || firstCard)?.focus({ focusVisible: true });
|
|
320
493
|
}
|
|
321
494
|
|
|
322
495
|
function renderLanding() {
|
|
@@ -325,11 +498,11 @@
|
|
|
325
498
|
`<button type="button" class="ws-import-btn" id="ws-import-project" data-tip="Restore a project from an exported .zip file">↓ Import project…</button></div>`;
|
|
326
499
|
// Create affordances stay docked at the top, separate from existing projects. Drawing-first
|
|
327
500
|
// entries lead; importing the current Workflows model stays last because it is a different mode.
|
|
328
|
-
const createEntries =
|
|
329
|
-
.flatMap((
|
|
330
|
-
const d = WORKSPACE_APPS[
|
|
501
|
+
const createEntries = wsAppEntries
|
|
502
|
+
.flatMap((entry) => {
|
|
503
|
+
const d = WORKSPACE_APPS[entry.templateId];
|
|
331
504
|
const actions = d && Array.isArray(d.createActions) ? d.createActions : [];
|
|
332
|
-
return actions.map((action) => ({
|
|
505
|
+
return actions.map((action) => ({ entry, d, action }));
|
|
333
506
|
})
|
|
334
507
|
.sort((a, b) => {
|
|
335
508
|
if (a.action.kind === 'current' && b.action.kind !== 'current') return 1;
|
|
@@ -338,50 +511,92 @@
|
|
|
338
511
|
});
|
|
339
512
|
if (createEntries.length) {
|
|
340
513
|
html += `<div class="ws-create-grid">`;
|
|
341
|
-
for (const {
|
|
514
|
+
for (const { entry, action } of createEntries) {
|
|
342
515
|
const isDrawing = action.kind === 'drawing';
|
|
516
|
+
// Name the target workflow ONLY when the root has more than one live app behind it, so the
|
|
517
|
+
// ordinary card stays clean and the extra line means something wherever it does appear. It
|
|
518
|
+
// must also go on the aria-label: the button's own aria-label REPLACES the accessible name
|
|
519
|
+
// computed from its children, so a descendant span alone is silent to a screen reader.
|
|
520
|
+
const target = entry.ambiguous ? entry.appId : '';
|
|
343
521
|
html += `<button type="button" class="ws-seed${isDrawing ? ' ws-seed-drop' : ''}" ` +
|
|
344
|
-
`aria-label="${escapeAttr(action.label || action.headline)}" ` +
|
|
345
|
-
`data-seed-app="${escapeAttr(
|
|
346
|
-
(isDrawing ? ` data-seed-drop="${escapeAttr(
|
|
522
|
+
`aria-label="${escapeAttr((action.label || action.headline) + (target ? ` (on the ${target} workflow)` : ''))}" ` +
|
|
523
|
+
`data-seed-app="${escapeAttr(entry.appId)}" data-seed-template="${escapeAttr(entry.templateId)}" data-seed-action="${escapeAttr(action.kind)}"` +
|
|
524
|
+
(isDrawing ? ` data-seed-drop="${escapeAttr(entry.appId)}"` : '') +
|
|
347
525
|
`>` +
|
|
348
526
|
`<span class="plus">+</span>` +
|
|
349
527
|
`<span class="ws-seed-headline">${escapeHtml(action.headline)}</span>` +
|
|
350
528
|
(action.capability ? `<span class="ws-seed-capability">${escapeHtml(action.capability)}</span>` : '') +
|
|
351
529
|
`<span class="ws-seed-sub">${escapeHtml(action.sub)}</span>` +
|
|
530
|
+
(target
|
|
531
|
+
? `<span class="ws-seed-target" data-tip="You have more than one of these workflows installed.\nThis card creates on:\n${escapeAttr(target)}">On ${escapeHtml(target)}</span>`
|
|
532
|
+
: '') +
|
|
352
533
|
`</button>`;
|
|
353
534
|
}
|
|
354
535
|
html += `</div>`;
|
|
355
536
|
}
|
|
356
537
|
html += `<div class="ws-grid">`;
|
|
357
538
|
for (const p of projects) {
|
|
358
|
-
const d =
|
|
359
|
-
const displayApp =
|
|
539
|
+
const d = wsDescOf(p);
|
|
540
|
+
const displayApp = projectAppName(p);
|
|
360
541
|
const projectCapability = d && d.projectCapability ? d.projectCapability : '';
|
|
542
|
+
// The badge says what KIND of document this is — a renamed steel-model is still a Steel model,
|
|
543
|
+
// so it keeps saying so. The live workflow name is added beside it only when it DIFFERS from the
|
|
544
|
+
// built-in, where it is the one thing the badge can no longer tell you; an ordinary card renders
|
|
545
|
+
// no workflow name at all and reads exactly as before (the markup around it is restructured, so
|
|
546
|
+
// the RENDERED TEXT is what is unchanged, not the HTML). Mono + dim is this app's established
|
|
547
|
+
// "technical identifier, not prose" treatment (.rtn-wf, .wf-option-meta, and the timestamp .t
|
|
548
|
+
// right next to it), which keeps it from reading as a second capability line. The full value
|
|
549
|
+
// rides in the tip because the slug is the part that gets abbreviated when room runs out.
|
|
550
|
+
// Every segment is its own element so the layout can say which ones may be abbreviated and which
|
|
551
|
+
// may not — see .ws-meta-app. The separators stay real TEXT (not CSS ::before) so the line still
|
|
552
|
+
// reads as "Trace · westfield-trace · 2 h ago" to a screen reader and to a copy-paste.
|
|
553
|
+
const wfName = wsRenamed(p)
|
|
554
|
+
? `<span class="ws-sep"> · </span><span class="ws-meta-wf" data-tip="The workflow this project runs on:\n${escapeAttr(p.app)}">${escapeHtml(p.app)}</span>`
|
|
555
|
+
: '';
|
|
361
556
|
html += `<div class="ws-card" role="button" tabindex="0" data-open="${escapeAttr(p.id)}">` +
|
|
362
557
|
`<span class="ws-thumb"><span class="ws-kind">${escapeHtml(displayApp)}</span>▦</span>` +
|
|
363
558
|
`<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
|
|
364
559
|
(projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
|
|
365
|
-
`<span class="ws-meta">${escapeHtml(displayApp)} ·
|
|
560
|
+
`<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
|
|
366
561
|
`<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}" aria-label="Project actions" data-tip="Rename · Duplicate · Export · Archive">⋯</button>` +
|
|
367
562
|
`</span></div>`;
|
|
368
563
|
}
|
|
369
564
|
html += `</div>`;
|
|
370
|
-
// Empty state
|
|
565
|
+
// Empty state — but ONLY when the list really is empty. A failed load also leaves `projects`
|
|
566
|
+
// empty, and telling someone with 11 projects "No projects yet — start one" is a lie that reads
|
|
567
|
+
// like their work is gone. The toast alone can't carry this: it auto-dismisses, and the false
|
|
568
|
+
// sentence stays on screen. Say what happened and offer the retry instead.
|
|
371
569
|
if (!projects.length) {
|
|
372
|
-
|
|
373
|
-
|
|
570
|
+
if (projectsLoadError) {
|
|
571
|
+
// role=status/polite, not alert: this can appear on an ordinary repaint (any action that
|
|
572
|
+
// re-runs loadProjects re-renders it), and assertive would interrupt a screen-reader user
|
|
573
|
+
// each time. Matches every other live region in this app.
|
|
574
|
+
const guess = projectsErrorHint(projectsLoadError);
|
|
575
|
+
html += `<div class="ws-empty-note ws-load-error" role="status" aria-live="polite">`
|
|
576
|
+
+ `<b>Couldn’t load your projects.</b> `
|
|
577
|
+
+ (guess ? `${escapeHtml(guess)} ` : '')
|
|
578
|
+
+ `<span class="ws-load-error-detail">${escapeHtml(projectsLoadError)}</span>`
|
|
579
|
+
+ ` <button type="button" id="ws-retry-projects">↻ Try again</button></div>`;
|
|
580
|
+
} else {
|
|
581
|
+
const note = 'No projects yet — start one from the cards above, or Import project to restore an exported .zip.';
|
|
582
|
+
html += `<div class="ws-empty-note">${escapeHtml(note)}${archived.length ? ' You have archived projects below.' : ''}</div>`;
|
|
583
|
+
}
|
|
374
584
|
}
|
|
375
585
|
// Archived ("Trash") section — a collapsed disclosure below the live grid, only when non-empty.
|
|
376
586
|
// Demoted rows (muted, no thumb) read as "put away"; each offers Restore + a guarded Delete.
|
|
377
587
|
if (archived.length) {
|
|
378
588
|
let rows = '';
|
|
379
589
|
for (const p of archived) {
|
|
380
|
-
const displayApp =
|
|
590
|
+
const displayApp = projectAppName(p);
|
|
591
|
+
// Tooltip only, deliberately: the Trash is a scan-and-act list where the user's own project
|
|
592
|
+
// NAME is the identifier (it doesn't even carry projectCapability), and a third clause on an
|
|
593
|
+
// already-compact dim line works against that. The disambiguating value lands where it is
|
|
594
|
+
// actionable — the live grid, one Restore away.
|
|
595
|
+
const wfTip = wsRenamed(p) ? ` data-tip="The workflow this project runs on:\n${escapeAttr(p.app)}"` : '';
|
|
381
596
|
rows += `<div class="ws-archived-row">` +
|
|
382
597
|
`<span class="ws-archived-info">` +
|
|
383
598
|
`<span class="ws-archived-name">${escapeHtml(p.name)}</span>` +
|
|
384
|
-
`<span class="ws-archived-meta">${escapeHtml(displayApp)} · archived <span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span>` +
|
|
599
|
+
`<span class="ws-archived-meta"${wfTip}>${escapeHtml(displayApp)} · archived <span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span>` +
|
|
385
600
|
`</span>` +
|
|
386
601
|
`<span class="ws-archived-actions">` +
|
|
387
602
|
`<button type="button" class="btn-mini ws-restore" data-restore="${escapeAttr(p.id)}" data-tip="Un-archive — returns to the live grid">↺ Restore</button>` +
|
|
@@ -395,6 +610,7 @@
|
|
|
395
610
|
`</details>`;
|
|
396
611
|
}
|
|
397
612
|
$landing.innerHTML = html;
|
|
613
|
+
reflashCard(); // a repaint must not swallow an in-flight confirmation glow
|
|
398
614
|
}
|
|
399
615
|
|
|
400
616
|
$landing.addEventListener('click', async (e) => {
|
|
@@ -404,17 +620,22 @@
|
|
|
404
620
|
if (restore) { e.stopPropagation(); unarchiveProject(restore.dataset.restore); return; }
|
|
405
621
|
const del = e.target.closest('[data-delete-archived]');
|
|
406
622
|
if (del) { e.stopPropagation(); deleteArchivedProject(del.dataset.deleteArchived); return; }
|
|
623
|
+
if (e.target.closest('#ws-retry-projects')) { e.stopPropagation(); retryProjects(); return; }
|
|
407
624
|
if (e.target.closest('#ws-import-project')) { importProject(); return; }
|
|
408
625
|
const card = e.target.closest('[data-open]');
|
|
409
626
|
if (card) { openProject(card.dataset.open); return; }
|
|
410
627
|
const seed = e.target.closest('[data-seed-app]');
|
|
411
628
|
if (seed) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
629
|
+
// Two ids, and they are not interchangeable: create on the LIVE app (`seed-app`), but look the
|
|
630
|
+
// descriptor up by its lineage ROOT (`seed-template`) — after a rename the live id answers to no
|
|
631
|
+
// descriptor, and the built-in id answers to no installed app.
|
|
632
|
+
const appId = seed.dataset.seedApp;
|
|
633
|
+
const templateId = seed.dataset.seedTemplate || appId;
|
|
634
|
+
if (!WORKSPACE_APPS[templateId]) return;
|
|
635
|
+
if (seed.dataset.seedAction === 'drawing') {
|
|
415
636
|
const files = await pickDrawingFiles($seedFile); // drop-a-drawing: open the picker
|
|
416
|
-
if (files.length) createFromDrawing(
|
|
417
|
-
} else createSeeded(
|
|
637
|
+
if (files.length) createFromDrawing(appId, templateId, files);
|
|
638
|
+
} else createSeeded(appId, templateId); // takeoff import
|
|
418
639
|
}
|
|
419
640
|
});
|
|
420
641
|
$landing.addEventListener('keydown', (e) => {
|
|
@@ -452,7 +673,8 @@
|
|
|
452
673
|
e.preventDefault();
|
|
453
674
|
zone.classList.remove('drag-over');
|
|
454
675
|
const files = Array.from((e.dataTransfer && e.dataTransfer.files) || []);
|
|
455
|
-
|
|
676
|
+
// Same two ids as the click path — the dropzone IS the seed button, so it carries both.
|
|
677
|
+
if (files.length) createFromDrawing(zone.dataset.seedDrop, zone.dataset.seedTemplate || zone.dataset.seedDrop, files);
|
|
456
678
|
});
|
|
457
679
|
|
|
458
680
|
async function promptName(title, label, value) {
|
|
@@ -461,14 +683,16 @@
|
|
|
461
683
|
return res && typeof res.name === 'string' && res.name.trim() ? res.name.trim() : null;
|
|
462
684
|
}
|
|
463
685
|
|
|
464
|
-
|
|
686
|
+
// `appId` is the LIVE app to create on; `templateId` its lineage root, which supplies the wording.
|
|
687
|
+
// They differ whenever the workflow has been renamed or duplicated — see the seed-card comment.
|
|
688
|
+
async function createSeeded(appId, templateId) {
|
|
465
689
|
const name = await promptName('New project', 'Name this project', '');
|
|
466
690
|
if (!name) return;
|
|
467
691
|
try {
|
|
468
692
|
const { project, seeded } = await api('/api/projects', { method: 'POST', body: JSON.stringify({ name, app: appId, seedFromApp: true }) });
|
|
469
693
|
// Tell the truth about the import: seeded=false means there was no current model to copy
|
|
470
694
|
// (or it was unreadable) — the project is EMPTY, don't imply the model came across.
|
|
471
|
-
const seedLabel = (WORKSPACE_APPS[
|
|
695
|
+
const seedLabel = (WORKSPACE_APPS[templateId] && WORKSPACE_APPS[templateId].seedLabel) || 'model';
|
|
472
696
|
if (seeded) showToast(`Project "${project.name}" created from the current ${seedLabel}`, 'ok');
|
|
473
697
|
else showToast(`Project "${project.name}" created — empty (no current ${seedLabel} to import)`, 'warn');
|
|
474
698
|
track('workspace_project_created', { app: appId }); // takeoff-import create path
|
|
@@ -482,10 +706,10 @@
|
|
|
482
706
|
// v1. ROLLBACK on cancel/error — if the user cancels the name prompt, or the file can't be read,
|
|
483
707
|
// AFTER the row is created, archive the empty project so no dead, openable project is left
|
|
484
708
|
// behind (the row is created before the source exists — spec §4.1).
|
|
485
|
-
async function createFromDrawing(appId, files) {
|
|
709
|
+
async function createFromDrawing(appId, templateId, files) {
|
|
486
710
|
// Ask for the name FIRST (before creating a row) so the common "cancel the prompt" path never
|
|
487
711
|
// creates anything to roll back.
|
|
488
|
-
const name = await promptName(`New ${
|
|
712
|
+
const name = await promptName(`New ${descDisplayName(templateId)} project`, 'Name this project', '');
|
|
489
713
|
if (!name) return;
|
|
490
714
|
let project;
|
|
491
715
|
try {
|
|
@@ -533,23 +757,38 @@
|
|
|
533
757
|
let p = projects.find((x) => x.id === id);
|
|
534
758
|
if (!p) { try { p = (await api('/api/projects')).projects.find((x) => x.id === id); } catch { /* fall through */ } }
|
|
535
759
|
if (!p) { showToast('Project not found — it may have been archived.', 'warn'); return loadProjects(); }
|
|
536
|
-
// Never a broken open (spec §3.2): a project whose app has no client descriptor
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
|
|
760
|
+
// Never a broken open (spec §3.2): a project whose app has no client descriptor can't be rendered
|
|
761
|
+
// — toast and bail BEFORE mutating any view state, matching the create-card skip. wsApp() would
|
|
762
|
+
// return null for it and the frame wiring would fail.
|
|
763
|
+
//
|
|
764
|
+
// Resolving through the lineage root took RENAMED and DUPLICATED apps out of this branch, which is
|
|
765
|
+
// the whole point of that change — so what remains is the genuinely unknown app: a workspace app
|
|
766
|
+
// we ship no descriptor for. The copy therefore names that, and says what can be done about it,
|
|
767
|
+
// rather than describing a state the user can no longer get themselves into by renaming.
|
|
768
|
+
if (!wsDescOf(p)) {
|
|
769
|
+
showToast('Workspaces has no view for this project’s app yet — ask the AI to add one.', 'warn');
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
540
772
|
current = p;
|
|
541
773
|
exportState = null;
|
|
542
774
|
teklaReadinessState = null;
|
|
543
775
|
track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
|
|
544
776
|
lastRevState = 'none'; stopRevisionPoll(); // fresh project — drop any prior revision-poll state
|
|
777
|
+
// Per-project, like everything above it: never let one project's answer describe another's. Not
|
|
778
|
+
// observable today (every history render is preceded by a fetch that sets it, and a failed fetch
|
|
779
|
+
// renders no rows), but leaving a stale cross-project value in place is the shape of bug this
|
|
780
|
+
// file resets state to avoid — and the next path that renders rows would inherit it.
|
|
781
|
+
histDiffSupported = false;
|
|
545
782
|
$projName.textContent = p.name;
|
|
546
783
|
$crumbName.textContent = p.name;
|
|
547
|
-
$status.textContent =
|
|
784
|
+
$status.textContent = projectAppName(p);
|
|
548
785
|
// Lazily src the frames once per project; switching steps only toggles hidden so the
|
|
549
786
|
// editor's state survives a Source⇄Traced round-trip. Frame URLs come from the app descriptor:
|
|
550
787
|
// the 'model' frame loads the app's editor; the 'drawings' frame loads its filter (steel) OR is
|
|
551
788
|
// left empty when the app has no filter step (vectorize — its Source step shows a placeholder).
|
|
552
|
-
const d =
|
|
789
|
+
const d = wsDescOf(p); // guaranteed present — the guard above bailed on an unknown app
|
|
790
|
+
// The LIVE app id, deliberately: the frames address the server with it (contract reads, saves),
|
|
791
|
+
// and after a rename only the live id resolves. Only the descriptor came from the lineage root.
|
|
553
792
|
const qs = `?app=${encodeURIComponent(p.app)}&project=${encodeURIComponent(p.id)}`;
|
|
554
793
|
frames.model.dataset.want = `${d.editor}${qs}`;
|
|
555
794
|
frames.drawings.dataset.want = d.filter ? `${d.filter}${qs}` : '';
|
|
@@ -649,11 +888,11 @@
|
|
|
649
888
|
if (stillOpen && !$wsHistory.hidden && res && res.version && Number.isInteger(Number(res.version.n))) {
|
|
650
889
|
expandDiffOnce = { projectId: approvingProject.id, n: Number(res.version.n) };
|
|
651
890
|
}
|
|
652
|
-
showToast(`Approved — "${approvingProject.name}" is baked into ${
|
|
891
|
+
showToast(`Approved — "${approvingProject.name}" is baked into ${projectAppName(approvingProject)}`, 'ok');
|
|
653
892
|
track('workspace_project_approved', { app: approvingProject.app }); // a successful sign-off
|
|
654
893
|
// First Approve for this app calms the "✦ Start here" beacon (the document-archetype
|
|
655
894
|
// analog of a workflow's first Run); ticks the Review + Approve guide rows.
|
|
656
|
-
if (bridge.markWorkspaceApproved &&
|
|
895
|
+
if (bridge.markWorkspaceApproved && wsDescOf(approvingProject)?.docGuide) {
|
|
657
896
|
bridge.markWorkspaceApproved(approvingProject.app);
|
|
658
897
|
}
|
|
659
898
|
if (stillOpen) {
|
|
@@ -687,6 +926,23 @@
|
|
|
687
926
|
const w = frames.model && frames.model.contentWindow;
|
|
688
927
|
if (w && typeof w.clearFind === 'function') { try { w.clearFind(); } catch { /* iframe gone */ } }
|
|
689
928
|
}
|
|
929
|
+
// The steel editor's ⋯ "Revert to an earlier version…" calls this from inside the Model iframe
|
|
930
|
+
// (same-origin, same bridge as find/clearFind above). Reverting a project belongs to the version
|
|
931
|
+
// ledger — this only navigates to it. No project open = nothing to show, so it's a no-op rather
|
|
932
|
+
// than a switch into an empty History pane.
|
|
933
|
+
function wsOpenHistory() {
|
|
934
|
+
if (!current) return;
|
|
935
|
+
setStep('history');
|
|
936
|
+
// Move focus with the step. The click that gets here comes from a button inside the Model
|
|
937
|
+
// iframe, which setStep() has just hidden — focus would otherwise collapse to <body>, leaving a
|
|
938
|
+
// keyboard user with no visible focus and a screen reader with nothing announced. Landing on the
|
|
939
|
+
// History tab reproduces exactly where a manual click on that tab would have left them.
|
|
940
|
+
// focusVisible: the keypress that got here happened in the IFRAME, so this document's
|
|
941
|
+
// :focus-visible heuristic scores the focus as programmatic and paints no ring. Ask for it
|
|
942
|
+
// explicitly; engines that don't support the option ignore it and behave exactly as before.
|
|
943
|
+
const tab = $stepTabs.querySelector('button[data-step="history"]');
|
|
944
|
+
if (tab) tab.focus({ focusVisible: true });
|
|
945
|
+
}
|
|
690
946
|
// While focus is inside the editor iframe (the usual case on the Model step), the parent's Ctrl+F
|
|
691
947
|
// handler never sees the key — so the shell forwards Cmd/Ctrl+F from the same-origin editor up to
|
|
692
948
|
// the global openFind. Re-wired on every iframe (re)load; each load is a fresh contentWindow, so
|
|
@@ -1884,6 +2140,40 @@
|
|
|
1884
2140
|
`</div>`;
|
|
1885
2141
|
}
|
|
1886
2142
|
|
|
2143
|
+
// Links created this session, per project: `${projectId}:share-3d` -> { url, approvedAt }. Held in
|
|
2144
|
+
// memory only — the server keeps no record of what a project has shared, and inventing a durable
|
|
2145
|
+
// one here would imply a revoke story that does not exist yet.
|
|
2146
|
+
const shareLinks = new Map();
|
|
2147
|
+
|
|
2148
|
+
// The share card's state, same {meta, disabled, tip} shape as teklaCardState. It is the second
|
|
2149
|
+
// file:false export kind, and the first whose RESULT is a URL rather than a file.
|
|
2150
|
+
function shareCardState(approved) {
|
|
2151
|
+
if (!approved) return {
|
|
2152
|
+
meta: '<span class="e-status">Available after approval</span>',
|
|
2153
|
+
disabled: true,
|
|
2154
|
+
tip: 'Approve this version first',
|
|
2155
|
+
};
|
|
2156
|
+
const made = shareLinks.get(`${current.id}:share-3d`);
|
|
2157
|
+
// A link is a frozen snapshot of the version it was made from. Once the project is re-approved it
|
|
2158
|
+
// no longer shows the current model — and staying silent about that would be worse than for a
|
|
2159
|
+
// file export, because a recipient may already hold the URL and cannot be un-sent it.
|
|
2160
|
+
if (made && made.approvedAt !== current.approvedAt) return {
|
|
2161
|
+
meta: `<span class="e-status">Link is from an earlier version</span>`,
|
|
2162
|
+
disabled: false,
|
|
2163
|
+
tip: 'Create a new link to share the current approved model',
|
|
2164
|
+
};
|
|
2165
|
+
if (made) {
|
|
2166
|
+
const shown = made.url.replace(/^https:\/\//, '');
|
|
2167
|
+
return {
|
|
2168
|
+
meta: `<span class="e-done"><span class="chk">✓</span> <span class="t e-sharelink" data-tip="${escapeAttr(made.url)}">${escapeHtml(shown)}</span></span>` +
|
|
2169
|
+
`<span class="e-links"><button type="button" class="e-link" data-copyshare="1" data-tip="Copy the link to your clipboard">Copy</button></span>`,
|
|
2170
|
+
disabled: false,
|
|
2171
|
+
tip: '',
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
return { meta: '<span class="e-status">not created yet</span>', disabled: false, tip: '' };
|
|
2175
|
+
}
|
|
2176
|
+
|
|
1887
2177
|
function teklaCardState(approved) {
|
|
1888
2178
|
if (!approved) return {
|
|
1889
2179
|
meta: '<span class="e-status">Available after approval</span>',
|
|
@@ -1919,9 +2209,12 @@
|
|
|
1919
2209
|
function cardHtml(c, approved) {
|
|
1920
2210
|
let meta;
|
|
1921
2211
|
const busy = exportBusy.has(`${current.id}:${c.kind}`);
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
2212
|
+
// The two file:false kinds resolve their own status; everything else uses the file/receipt path
|
|
2213
|
+
// below. `special` keeps the branches from growing a third arm each time a kind is added.
|
|
2214
|
+
const special = c.kind === 'tekla' ? teklaCardState(approved)
|
|
2215
|
+
: c.kind === 'share-3d' ? shareCardState(approved) : null;
|
|
2216
|
+
if (special) {
|
|
2217
|
+
meta = special.meta;
|
|
1925
2218
|
} else if (!approved) {
|
|
1926
2219
|
meta = `<span class="e-status">Available after approval</span>`;
|
|
1927
2220
|
} else if (exportState == null) {
|
|
@@ -1940,15 +2233,21 @@
|
|
|
1940
2233
|
}
|
|
1941
2234
|
}
|
|
1942
2235
|
const exported = approved && c.file && exportState && exportState[c.kind] && exportState[c.kind].exportedAt;
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
const
|
|
1946
|
-
|
|
2236
|
+
// Re-labelled once a link exists, mirroring the file kinds' "Re-export" convention. Gated on the
|
|
2237
|
+
// in-memory record rather than exportState, which only ever tracks file exports.
|
|
2238
|
+
const shared = approved && c.kind === 'share-3d' && shareLinks.has(`${current.id}:share-3d`);
|
|
2239
|
+
const busyLabel = c.kind === 'tekla' ? 'Sending…' : c.kind === 'share-3d' ? 'Creating…' : 'Exporting…';
|
|
2240
|
+
const label = busy ? busyLabel : (exported || shared ? (c.kind === 'share-3d' ? 'Create new link' : 'Re-export') : c.verb);
|
|
2241
|
+
const disabled = special ? special.disabled : !approved;
|
|
2242
|
+
const busyTip = c.kind === 'tekla' ? 'Sending the approved model to Tekla'
|
|
2243
|
+
: c.kind === 'share-3d' ? 'Rendering the model and uploading the link' : 'Export in progress';
|
|
2244
|
+
const tip = busy ? busyTip
|
|
2245
|
+
: special ? special.tip : (approved ? '' : 'Approve this version first');
|
|
1947
2246
|
const dis = `${disabled && !busy ? ' disabled' : ''}${busy ? ' aria-disabled="true" aria-busy="true"' : ''}${tip ? ` data-tip="${escapeAttr(tip)}"` : ''}`;
|
|
1948
2247
|
return `<div class="ecard">` +
|
|
1949
2248
|
`<div class="e-top"><div class="e-ico">${escapeHtml(c.ico)}</div>` +
|
|
1950
2249
|
`<div><div class="e-name">${escapeHtml(c.name)}</div><div class="e-fmt">${escapeHtml(c.fmt)}</div></div></div>` +
|
|
1951
|
-
`<div class="e-meta${
|
|
2250
|
+
`<div class="e-meta${special ? ' e-meta-tekla' : ''}">${meta}</div>` +
|
|
1952
2251
|
receiptHtml(c.kind, approved) +
|
|
1953
2252
|
`<div class="e-act"><button type="button" data-export="${escapeAttr(c.kind)}"${dis}>↗ ${escapeHtml(label)}</button></div>` +
|
|
1954
2253
|
`</div>`;
|
|
@@ -1960,6 +2259,7 @@
|
|
|
1960
2259
|
'data-reveal',
|
|
1961
2260
|
'data-export-details',
|
|
1962
2261
|
'data-tekla-recovery',
|
|
2262
|
+
'data-copyshare', // the share-link Copy button — omitted here, a repaint mid-render steals its focus
|
|
1963
2263
|
];
|
|
1964
2264
|
|
|
1965
2265
|
function exportFocusIdentity(element) {
|
|
@@ -2052,7 +2352,7 @@
|
|
|
2052
2352
|
|
|
2053
2353
|
async function doExport(kind) {
|
|
2054
2354
|
if (!current) return;
|
|
2055
|
-
const app = current.app, projectId = current.id, approvedAt = current.approvedAt; // capture — the user may switch projects during the await
|
|
2355
|
+
const app = current.app, projectId = current.id, approvedAt = current.approvedAt, projectName = current.name; // capture — the user may switch projects, or leave, during the await
|
|
2056
2356
|
const busyKey = `${projectId}:${kind}`;
|
|
2057
2357
|
if (exportBusy.has(busyKey)) return;
|
|
2058
2358
|
exportBusy.add(busyKey);
|
|
@@ -2060,6 +2360,60 @@
|
|
|
2060
2360
|
// Carry the activated kind through the first replacement explicitly; later repaints infer
|
|
2061
2361
|
// focus normally, so moving elsewhere during a long export is still respected.
|
|
2062
2362
|
paintExports(current.approvedAt, kind);
|
|
2363
|
+
// A share link is two existing endpoints composed, not a new one: render the approved model to a
|
|
2364
|
+
// self-contained viewer document, then hand that document to the same upload the HTML report
|
|
2365
|
+
// Share button uses. Nothing about the hosting, the gate or the badge is special-cased here.
|
|
2366
|
+
if (kind === 'share-3d') {
|
|
2367
|
+
try {
|
|
2368
|
+
// `for=share` tells the server this document is about to be PUBLISHED, so it can refuse on an
|
|
2369
|
+
// AWARE too old to render the display modes this card offers. The local 3D view sends no flag.
|
|
2370
|
+
const rendered = await api(`/api/contract/${encodeURIComponent(app)}/export-3d?project=${encodeURIComponent(projectId)}&for=share`, { method: 'POST' });
|
|
2371
|
+
if (!rendered.ok || !rendered.report || !rendered.report.html) {
|
|
2372
|
+
throw new Error(rendered.error || 'the 3D render produced no document');
|
|
2373
|
+
}
|
|
2374
|
+
const html = rendered.report.html;
|
|
2375
|
+
const title = `${projectName || app} · 3D model`;
|
|
2376
|
+
// Measure the SERIALIZED body, not the raw HTML: JSON escaping on quote-heavy viewer markup
|
|
2377
|
+
// inflates the payload, so a document that reads as under the limit can still be over it once
|
|
2378
|
+
// sent — turning a preflight that was supposed to fail fast into a 413 after a long upload.
|
|
2379
|
+
// `kind` is in the measured string because it is in the sent string — the two must not drift.
|
|
2380
|
+
const body = JSON.stringify({ title, html, kind: 'model-3d' });
|
|
2381
|
+
const bytes = new Blob([body]).size;
|
|
2382
|
+
if (bytes > 5 * 1024 * 1024) {
|
|
2383
|
+
throw new Error(`This model is too large to share — ${(bytes / 1048576).toFixed(1)} MB, limit 5 MB.`);
|
|
2384
|
+
}
|
|
2385
|
+
const res = await api('/api/share-report', { method: 'POST', body });
|
|
2386
|
+
shareLinks.set(`${projectId}:share-3d`, { url: res.url, approvedAt });
|
|
2387
|
+
// The copy is tracked separately from the upload, and its failure never reaches the outer
|
|
2388
|
+
// catch: claiming "copied" when the clipboard was denied leaves the user pasting something
|
|
2389
|
+
// stale, and letting a missing navigator.clipboard throw would report a SUCCESSFUL share as
|
|
2390
|
+
// a failure. The link is on the card either way.
|
|
2391
|
+
let copied = false;
|
|
2392
|
+
try { await navigator.clipboard.writeText(res.url); copied = true; } catch { copied = false; }
|
|
2393
|
+
track('workspace_export', { app, kind });
|
|
2394
|
+
showToast(copied ? 'Share link created — copied to clipboard.' : 'Share link created — use Copy on the card.', 'ok');
|
|
2395
|
+
} catch (err) {
|
|
2396
|
+
const code = err && err.body && err.body.error;
|
|
2397
|
+
// The runtime refusal names the floor, not the pill's target: the footer pill installs
|
|
2398
|
+
// whatever the registry currently offers, which may be higher than the floor and would
|
|
2399
|
+
// otherwise read as a contradiction. Only the pill's STABLE label prefix is quoted.
|
|
2400
|
+
const awareVersion = err && err.body && err.body.version;
|
|
2401
|
+
const awareFloor = (err && err.body && err.body.floor) || '0.96.0';
|
|
2402
|
+
showToast(
|
|
2403
|
+
code === 'signed_out' ? 'Your FloLess sign-in has expired — sign in again to share.' :
|
|
2404
|
+
code === 'no_subscription' ? 'A FloLess subscription is required to share a model.' :
|
|
2405
|
+
code === 'rate_limited' ? 'Share limit reached (30 per hour) — try again shortly.' :
|
|
2406
|
+
code === 'aware_too_old' ? (awareVersion
|
|
2407
|
+
? `AWARE v${awareVersion} is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`
|
|
2408
|
+
: `Your installed AWARE is too old to share a faithful model — Realistic and Shadowed need v${awareFloor} or later. Click ↑ Upgrade AWARE in the footer, then share again.`) :
|
|
2409
|
+
(err && err.message ? err.message : String(err)),
|
|
2410
|
+
'warn');
|
|
2411
|
+
} finally {
|
|
2412
|
+
exportBusy.delete(busyKey);
|
|
2413
|
+
if (current && current.id === projectId) paintExports(current.approvedAt);
|
|
2414
|
+
}
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2063
2417
|
try {
|
|
2064
2418
|
const res = await api(exportUrl(kind), { method: 'POST' });
|
|
2065
2419
|
track('workspace_export', { app, kind }); // a successful export/bake (e.g. { app:'vectorize', kind:'svg' })
|
|
@@ -2165,6 +2519,26 @@
|
|
|
2165
2519
|
if (open) { fileAction('/api/open-file', open.dataset.openfile, 'Couldn’t open the file'); return; }
|
|
2166
2520
|
const rev = e.target.closest('[data-reveal]');
|
|
2167
2521
|
if (rev) { fileAction('/api/reveal', rev.dataset.reveal, 'Couldn’t reveal the file'); return; }
|
|
2522
|
+
const cp = e.target.closest('[data-copyshare]');
|
|
2523
|
+
if (cp) {
|
|
2524
|
+
const made = current && shareLinks.get(`${current.id}:share-3d`);
|
|
2525
|
+
if (!made) return;
|
|
2526
|
+
// Toast confirmation, matching how the rest of the app confirms a copy — no inline label swap.
|
|
2527
|
+
// navigator.clipboard can be absent under a restricted browser policy, and dereferencing
|
|
2528
|
+
// .writeText then throws SYNCHRONOUSLY — before any .catch() on the returned promise could
|
|
2529
|
+
// run. That matters most here: the automatic copy guards this case (see the try/catch where
|
|
2530
|
+
// the link is created) and tells the user to press THIS button, so an unguarded throw would
|
|
2531
|
+
// fail exactly the fallback we pointed them at, and silently.
|
|
2532
|
+
void (async () => {
|
|
2533
|
+
try {
|
|
2534
|
+
await navigator.clipboard.writeText(made.url);
|
|
2535
|
+
showToast('Link copied to clipboard', 'ok');
|
|
2536
|
+
} catch {
|
|
2537
|
+
showToast('Couldn’t copy the link', 'warn');
|
|
2538
|
+
}
|
|
2539
|
+
})();
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2168
2542
|
});
|
|
2169
2543
|
|
|
2170
2544
|
// ── Revisions: attach a revised drawing set → queue a compose-time read (Slice 4b) ──
|
|
@@ -2328,6 +2702,12 @@
|
|
|
2328
2702
|
};
|
|
2329
2703
|
|
|
2330
2704
|
let versions = []; // last-rendered ledger (newest first)
|
|
2705
|
+
// Whether the semantic comparison applies to THIS project — the SERVER's answer, so the rule lives
|
|
2706
|
+
// in one place instead of being duplicated here. Today that answer is "is this app steel-model",
|
|
2707
|
+
// decided from the live app id; it is NOT contract-type aware (that work is deferred — see
|
|
2708
|
+
// `appSupportsDiff`'s header server-side). Set on every versions fetch; the conservative default is
|
|
2709
|
+
// false so a failed or never-run fetch shows no toggle rather than a dead one.
|
|
2710
|
+
let histDiffSupported = false;
|
|
2331
2711
|
let expandDiffOnce = null; // { projectId, n }: successful Approve opens only that project's new row
|
|
2332
2712
|
|
|
2333
2713
|
function changeCellHtml(v, canDiff) {
|
|
@@ -2360,11 +2740,18 @@
|
|
|
2360
2740
|
const action = v.current
|
|
2361
2741
|
? ''
|
|
2362
2742
|
: `<button type="button" class="btn-mini" data-rollback="${escapeAttr(String(v.n))}" data-tip="Restore this version as a new version">↺ Rollback</button>`;
|
|
2363
|
-
// "What changed" disclosure — only when the
|
|
2364
|
-
//
|
|
2365
|
-
//
|
|
2743
|
+
// "What changed" disclosure — only when the semantic diff APPLIES and the version has a
|
|
2744
|
+
// predecessor (n>1). v1 is the baseline, and a no-diff app (vectorize) gets NO toggle on ANY row —
|
|
2745
|
+
// an ABSENT control, never a disabled one (spec §4.4, mirroring the v1-baseline branch).
|
|
2746
|
+
//
|
|
2747
|
+
// `histDiffSupported` is the SERVER's answer (`diffSupported` on the versions response) rather
|
|
2748
|
+
// than this side's own reading of the app descriptor. Not because the server currently knows
|
|
2749
|
+
// more — it applies the same "is this steel-model" rule — but because TWO copies of one rule
|
|
2750
|
+
// drift, and when they drift this way the user gets a "View detailed changes" control that then
|
|
2751
|
+
// answers 409: an affordance they can never satisfy. One answer, from the side that also owns the
|
|
2752
|
+
// refusal. Defaults to the descriptor when the field is absent (an older server).
|
|
2366
2753
|
const isApprovalBaseline = v.kind === 'approve' && v.changeSummary && v.changeSummary.from == null;
|
|
2367
|
-
const canDiff =
|
|
2754
|
+
const canDiff = histDiffSupported && Number(v.n) > 1 && !isApprovalBaseline;
|
|
2368
2755
|
const verRow = `<tr class="${v.current ? 'current' : ''}" data-ver="${escapeAttr(String(v.n))}">` +
|
|
2369
2756
|
`<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
|
|
2370
2757
|
`<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
|
|
@@ -2391,6 +2778,8 @@
|
|
|
2391
2778
|
try {
|
|
2392
2779
|
const r = await api(`/api/projects/${encodeURIComponent(id)}/versions`);
|
|
2393
2780
|
rows = Array.isArray(r.versions) ? r.versions : [];
|
|
2781
|
+
// Absent on an older server → fall back to the descriptor, which is the pre-change behaviour.
|
|
2782
|
+
histDiffSupported = typeof r.diffSupported === 'boolean' ? r.diffSupported : !!(wsApp() && wsApp().diff);
|
|
2394
2783
|
approvedAt = r.approvedAt || undefined;
|
|
2395
2784
|
current.approvedAt = approvedAt; // re-sync — an in-editor autosave clears the sign-off server-side
|
|
2396
2785
|
} catch (err) {
|
|
@@ -2470,6 +2859,15 @@
|
|
|
2470
2859
|
try {
|
|
2471
2860
|
await api(`/api/projects/${encodeURIComponent(proj.id)}/versions/${encodeURIComponent(n)}/rollback`, { method: 'POST' });
|
|
2472
2861
|
proj.approvedAt = undefined; // rollback re-locks exports (the server cleared the sign-off)
|
|
2862
|
+
// Drop the editor's localStorage draft, or the rollback silently undoes itself. restoreSaved()
|
|
2863
|
+
// re-overlays that draft's members/dims/details on the editor's NEXT boot whenever dataSig()
|
|
2864
|
+
// still matches — and dataSig() is only sheet + segment count, which member edits never change.
|
|
2865
|
+
// The SSE path that normally clears it cannot help here: when History is the visible step the
|
|
2866
|
+
// line below leaves this iframe at about:blank, so there is no editor document listening for
|
|
2867
|
+
// the contract-changed broadcast. After a rollback the server contract is the truth, so a local
|
|
2868
|
+
// draft can only put the user's pre-rollback edits back on top of the version they restored.
|
|
2869
|
+
// Same origin, and the key is the one the editor builds from ?app=.
|
|
2870
|
+
try { localStorage.removeItem('steeltakeoff:edits:v1:' + proj.app); } catch (_) { /* blocked storage */ }
|
|
2473
2871
|
showToast(`Restored v${n} as a new version — Exports re-locked; Approve to re-enable`, 'ok');
|
|
2474
2872
|
// Reload the editor iframe so it shows the restored geometry (it fetched the contract on load).
|
|
2475
2873
|
frames.model.dataset.loaded = '';
|
|
@@ -2759,12 +3157,44 @@
|
|
|
2759
3157
|
// animationend handler ends the glow ~0.6s later; if a reconcile repaint (or reduced-motion, where
|
|
2760
3158
|
// there is no animation) gets there first, renderLanding's full innerHTML rebuild drops `is-new`
|
|
2761
3159
|
// anyway — so nothing sticks either way.
|
|
3160
|
+
// The card to re-glow after a repaint. The landing now paints as soon as the projects list lands
|
|
3161
|
+
// (~200 ms) instead of after /api/apps (~1.2 s), so the reconcile repaint arrives a third of the
|
|
3162
|
+
// way through the 0.6 s pulse and innerHTML rebuilding drops `is-new` mid-animation — killing the
|
|
3163
|
+
// confirmation glow in the very flows it was added for (rename / duplicate / archive / import).
|
|
3164
|
+
// renderLanding() re-applies it for this id, and the animationend handler clears it.
|
|
3165
|
+
let flashId = null;
|
|
3166
|
+
let flashTimer = null;
|
|
3167
|
+
// End the glow. Driven by animationend AND a timer, because under
|
|
3168
|
+
// `prefers-reduced-motion: reduce` app.css sets `animation:none` — animationend then NEVER fires,
|
|
3169
|
+
// and .is-new also carries a static box-shadow, so without the timer the highlight (and the
|
|
3170
|
+
// re-arming below) would stick to that card for the rest of the session. Guarded by id so a
|
|
3171
|
+
// second flash's arrival doesn't let the first one's handler clear it.
|
|
3172
|
+
function endFlash(id, el) {
|
|
3173
|
+
if (flashId !== id) return;
|
|
3174
|
+
flashId = null;
|
|
3175
|
+
if (flashTimer) { clearTimeout(flashTimer); flashTimer = null; }
|
|
3176
|
+
el.classList.remove('is-new');
|
|
3177
|
+
}
|
|
3178
|
+
function armFlash(id, el) {
|
|
3179
|
+
el.classList.add('is-new');
|
|
3180
|
+
el.addEventListener('animationend', () => endFlash(id, el), { once: true });
|
|
3181
|
+
if (flashTimer) clearTimeout(flashTimer);
|
|
3182
|
+
flashTimer = setTimeout(() => endFlash(id, el), 900); // > the 0.6s pulse; the reduced-motion path's only exit
|
|
3183
|
+
}
|
|
2762
3184
|
function flashCard(id, opts) {
|
|
2763
3185
|
const el = $landing.querySelector(`.ws-card[data-open="${escapeAttr(id)}"]`);
|
|
2764
3186
|
if (!el) return;
|
|
2765
3187
|
if (opts && opts.scroll) el.scrollIntoView({ block: 'nearest' });
|
|
2766
|
-
|
|
2767
|
-
|
|
3188
|
+
flashId = id;
|
|
3189
|
+
armFlash(id, el);
|
|
3190
|
+
}
|
|
3191
|
+
// Re-arm the glow on the freshly-rendered card after renderLanding() replaced the DOM. A rebuilt
|
|
3192
|
+
// element restarts the animation on its own — it is a new node, not a re-classed one.
|
|
3193
|
+
function reflashCard() {
|
|
3194
|
+
if (!flashId) return;
|
|
3195
|
+
const el = $landing.querySelector(`.ws-card[data-open="${escapeAttr(flashId)}"]`);
|
|
3196
|
+
if (!el) { flashId = null; return; } // card is gone (archived/deleted) — drop the pending flash
|
|
3197
|
+
armFlash(flashId, el);
|
|
2768
3198
|
}
|
|
2769
3199
|
|
|
2770
3200
|
// rename/duplicate/archive on ONE project — driven by the landing-grid card ⋯ menu (the header
|
|
@@ -2922,7 +3352,7 @@
|
|
|
2922
3352
|
const rows = projects.slice().sort((a, b) => a.name.localeCompare(b.name));
|
|
2923
3353
|
let html = rows.map((p) => {
|
|
2924
3354
|
const pid = escapeAttr(p.id);
|
|
2925
|
-
const displayApp =
|
|
3355
|
+
const displayApp = projectAppName(p);
|
|
2926
3356
|
const meta = `${escapeHtml(displayApp)} · ${escapeHtml(relAgo(p.updatedAt))}`;
|
|
2927
3357
|
// A PURE SWITCHER: no per-row Rename/Duplicate/Archive icons — project MANAGEMENT lives only on
|
|
2928
3358
|
// the landing cards' ⋯ menu (a picker that only lets you switch has one predictable affordance
|
|
@@ -3024,6 +3454,6 @@
|
|
|
3024
3454
|
if ($projPopover && !$projPopover.hidden && $projCombo && !$projCombo.contains(e.target)) closeProjCombo(false);
|
|
3025
3455
|
});
|
|
3026
3456
|
|
|
3027
|
-
window.flolessWorkspaces = { setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind };
|
|
3457
|
+
window.flolessWorkspaces = { setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind, openHistory: wsOpenHistory };
|
|
3028
3458
|
applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
|
|
3029
3459
|
})();
|