@floless/app 0.157.0 → 0.159.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/cli-actions.mjs +7 -0
  2. package/dist/floless-server.cjs +188306 -155284
  3. package/dist/schemas/drawing-check.profile.v1.schema.json +33 -1
  4. package/dist/skills/floless-app-actions/SKILL.md +26 -5
  5. package/dist/skills/floless-app-bridge/SKILL.md +5 -3
  6. package/dist/skills/floless-app-knowledge/SKILL.md +14 -1
  7. package/dist/skills/floless-app-knowledge/references/schema.md +4 -1
  8. package/dist/skills/floless-app-onboarding/SKILL.md +67 -4
  9. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +7 -4
  10. package/dist/skills/floless-app-queue/SKILL.md +3 -1
  11. package/dist/skills/floless-app-steel-model/SKILL.md +41 -1
  12. package/dist/skills/floless-app-steel-takeoff/SKILL.md +71 -1
  13. package/dist/skills/floless-app-workflows/SKILL.md +6 -3
  14. package/dist/web/agents.js +12 -5
  15. package/dist/web/app.css +229 -27
  16. package/dist/web/app.js +6 -0
  17. package/dist/web/aware.js +275 -64
  18. package/dist/web/chat.css +60 -22
  19. package/dist/web/chat.js +396 -59
  20. package/dist/web/commands-shell.js +546 -11
  21. package/dist/web/commands-steel.js +1 -0
  22. package/dist/web/drawing-check-editor.html +10 -0
  23. package/dist/web/drawing-check-editor.js +44 -0
  24. package/dist/web/guide.js +4 -2
  25. package/dist/web/index.html +66 -12
  26. package/dist/web/instructor.js +21 -9
  27. package/dist/web/kb-categories.js +351 -0
  28. package/dist/web/kb-graph-worker.js +73 -0
  29. package/dist/web/pages.js +185 -19
  30. package/dist/web/project-access.js +67 -8
  31. package/dist/web/project-modules.js +474 -0
  32. package/dist/web/project-workflows.js +274 -0
  33. package/dist/web/run-page-view.js +353 -0
  34. package/dist/web/steel-3d-core.js +46 -0
  35. package/dist/web/steel-3d-view.js +8 -38
  36. package/dist/web/steel-editor.html +225 -43
  37. package/dist/web/tab-signal.js +323 -0
  38. package/dist/web/terminal-requests.js +48 -7
  39. package/dist/web/workspace-root-recovery.js +119 -0
  40. package/dist/web/workspaces.js +1597 -220
  41. package/launch-starting-page.mjs +184 -0
  42. package/launch.mjs +214 -73
  43. package/package.json +7 -1
  44. package/dist/web/report-files.js +0 -50
package/dist/web/pages.js CHANGED
@@ -88,7 +88,7 @@
88
88
 
89
89
  // #2262 slice 4: a list row says where its link stands — never "Shared" for a link that isn't open yet or is going.
90
90
  const LIST_CHIP = { live: 'Shared', 'pending-publish': 'Publishing…', 'pending-revoke': 'Revoke waiting' };
91
- function rowHtml(home, p) {
91
+ function rowHtml(home, p, view = {}) {
92
92
  if (p.damaged) {
93
93
  // Delete is offered only where deleting loses nothing good: a broken or record-less Page. A Page saved
94
94
  // by a newer FloLess is fine (update to open it), and a shortcut folder points somewhere else.
@@ -103,7 +103,7 @@
103
103
  ${canDelete ? `<button type="button" class="ghost pg-row-delete" data-command-id="shell.page-delete-unreadable#${esc(p.id)}" data-home="${esc(home)}" data-page="${esc(p.id)}">Delete</button>` : ''}
104
104
  </div>`;
105
105
  }
106
- const meta = [sourceText(p.source), versionsText(p.versionCount), p.sequence ? 'Has an order' : '', `Updated ${ago(p.updatedAt)}`].filter(Boolean).join(' · ');
106
+ const meta = [...(view.lead || [sourceText(p.source)]), versionsText(p.versionCount), p.sequence ? 'Has an order' : '', `Updated ${ago(p.updatedAt)}`].filter(Boolean).join(' · ');
107
107
  // Only an order FloLess did not read is flagged on the row; a read one is the plain "Has an order".
108
108
  const seqChip = p.sequence && (p.sequence !== 'read' || p.sequencePartial) ? `<span class="pg-seq-chip is-warn">${esc(seqLabel({ order: p.sequence, partial: p.sequencePartial }))}</span>` : '';
109
109
  return `<div class="pg-row" role="listitem">
@@ -120,7 +120,7 @@
120
120
  if (w.page && typeof w.home === 'string') return rowHtml(w.home, w.page);
121
121
  return `<div class="pg-row pg-row-damaged" role="listitem">
122
122
  <div class="pg-row-text"><span class="pg-row-title">${esc(w.workflowName)}: its Page can’t be opened</span>
123
- <span class="pg-row-meta">${esc(w.note || 'FloLess couldn’t read this workflow’s Page.')}</span></div>
123
+ <span class="pg-row-meta">${esc(w.note || 'FloLess couldn’t read this workflow’s Page.')} Run the workflow again to save a new version; if this keeps happening, use Report an issue.</span></div>
124
124
  </div>`;
125
125
  }
126
126
 
@@ -174,6 +174,106 @@
174
174
  }
175
175
  }
176
176
 
177
+ // ── The Workflows landing's Pages tab (#2568): every workflow's Page, wherever it is kept ─────────────────────────
178
+
179
+ /** The last list read, so a landing repaint shows it at once while the fresh one loads — for this workspace only. */
180
+ let wfRowsCache = null;
181
+ let wfNote = '';
182
+ let wfRoot = null;
183
+ // A change of workspace (the first word about it included) drops what was read and redraws each open list ONCE; an
184
+ // answer still out for the workspace that was open before is simply dropped (see renderWorkflowsList), never re-asked.
185
+ window.addEventListener('floless:workspace-root-state', (event) => {
186
+ const root = event.detail && event.detail.root;
187
+ const id = root ? `${root.rootId}#${root.generation}` : null;
188
+ if (id === wfRoot) return;
189
+ wfRoot = id;
190
+ wfRowsCache = null; wfNote = '';
191
+ for (const e of [...lists]) {
192
+ if (e.kind !== 'workflows') continue;
193
+ if (!e.container.isConnected) { lists.delete(e); continue; }
194
+ void renderWorkflowsList(e.container, e.opts);
195
+ }
196
+ });
197
+ const cachedRows = () => wfRowsCache;
198
+ const ownerText = (w) => (w.owner?.kind === 'project' ? (w.owner.name || 'A project') : 'Workspace');
199
+
200
+ function workflowPageRowHtml(w) {
201
+ if (!(w.page && typeof w.home === 'string')) return workflowRowHtml(w);
202
+ // A workflow's Page is titled after the workflow, so its name is repeated only when the two differ.
203
+ const named = w.page?.title && w.page.title.trim() === String(w.workflowName).trim() ? [] : [w.workflowName];
204
+ return rowHtml(w.home, w.page, { lead: [...named, ownerText(w), ...(w.archived ? ['Archived'] : [])] });
205
+ }
206
+
207
+ function wfMatches(w, terms) {
208
+ const hay = `${w.workflowName} ${w.page?.title || ''} ${ownerText(w)}`.toLowerCase();
209
+ return terms.every((t) => hay.includes(t));
210
+ }
211
+
212
+ function paintWorkflowsList(container, rows, opts) {
213
+ const query = String(opts?.getQuery?.() ?? '').trim();
214
+ const focused = container.contains(document.activeElement) ? document.activeElement?.getAttribute('data-command-id') : null;
215
+ const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
216
+ const shown = rows.filter((w) => wfMatches(w, terms));
217
+ container.dataset.pgwfState = 'ready';
218
+ if (!rows.length) {
219
+ container.innerHTML = `<div class="pg-empty"><p>No workflow has a Page yet. Every successful run of a workflow that makes a report adds a version to its Page.</p>
220
+ <p><button type="button" class="ghost pg-wf-act" data-act="show-workflows" data-command-id="shell.workflows-landing-pages-show-workflows">Show workflows</button></p></div>`;
221
+ } else if (!shown.length) {
222
+ container.innerHTML = '<div class="pg-empty" role="status"><p class="pg-wf-nomatch"></p><p><button type="button" class="ghost pg-wf-act" data-act="clear-search" data-command-id="shell.workflows-landing-pages-clear-search">Clear search</button></p></div>';
223
+ container.querySelector('.pg-wf-nomatch').textContent = `No Page matches “${query}”.`; // text, never markup: it echoes what was typed
224
+ } else {
225
+ container.innerHTML = `<div class="pg-list" role="list" aria-label="Pages from workflows">${shown.map(workflowPageRowHtml).join('')}</div>`;
226
+ }
227
+ if (wfNote) {
228
+ const note = document.createElement('p');
229
+ note.className = 'pg-wf-note';
230
+ note.setAttribute('role', 'status');
231
+ note.textContent = wfNote;
232
+ container.prepend(note);
233
+ }
234
+ if (focused && document.activeElement === document.body && container.isConnected) {
235
+ [...container.querySelectorAll('[data-command-id]')].find((el) => el.getAttribute('data-command-id') === focused)?.focus({ preventScroll: true });
236
+ }
237
+ }
238
+
239
+ /** Draw the list again from what was last read (a search, a tab switch back): nothing is fetched. */
240
+ function repaintWorkflowsList(container) {
241
+ const entry = [...lists].find((e) => e.kind === 'workflows' && e.container === container);
242
+ if (entry && cachedRows() && container.dataset.pgwfState === 'ready') paintWorkflowsList(container, cachedRows(), entry.opts);
243
+ }
244
+
245
+ /**
246
+ * Render every workflow's Page into `container`. `opts.getQuery()` is the landing's search text; `opts.onAction(act)`
247
+ * hears the buttons that leave this list ('show-workflows', 'clear-search'). Registered with the live lists, so a
248
+ * Page that changes re-reads it.
249
+ */
250
+ async function renderWorkflowsList(container, opts = {}) {
251
+ if (!container) return;
252
+ const entry = { container, kind: 'workflows', opts };
253
+ for (const e of [...lists]) if (e.container === container) lists.delete(e);
254
+ lists.add(entry);
255
+ const token = (container.dataset.pagesToken = String(Math.random()));
256
+ if (cachedRows()) paintWorkflowsList(container, cachedRows(), opts);
257
+ else { container.dataset.pgwfState = 'loading'; container.innerHTML = '<p class="pg-loading-line">Loading Pages…</p>'; }
258
+ // An answer is used only by the request still current for this list, while the list is on screen. A workspace change
259
+ // redraws every open list (a new token), so an answer read for the workspace that was open before is dropped here.
260
+ const current = () => container.dataset.pagesToken === token && container.isConnected;
261
+ let body;
262
+ try { body = await api('/api/pages/workflows'); } catch (err) {
263
+ if (!current()) return;
264
+ console.warn('The workflows’ Pages could not be read', err);
265
+ wfRowsCache = null; wfNote = '';
266
+ container.dataset.pgwfState = 'error';
267
+ container.innerHTML = `<div class="pg-empty" role="alert"><p>FloLess couldn’t load the workflows’ Pages. Check that FloLess is running, then try again.</p>
268
+ <p><button type="button" class="ghost pg-wf-act" data-act="retry" data-command-id="shell.workflows-landing-pages-retry">Try again</button></p></div>`;
269
+ return;
270
+ }
271
+ if (!current()) return;
272
+ wfRowsCache = (Array.isArray(body.workflowPages) ? body.workflowPages : []).filter((w) => w && typeof w.workflowName === 'string');
273
+ wfNote = typeof body.note === 'string' ? body.note : '';
274
+ paintWorkflowsList(container, wfRowsCache, opts);
275
+ }
276
+
177
277
  /** Tell the rest of the window a Page is gone, so nothing keeps offering to open it (the report viewer's links). */
178
278
  function announceDeleted(home, id) {
179
279
  window.dispatchEvent(new CustomEvent('floless:page-deleted', { detail: { home, id } }));
@@ -182,7 +282,8 @@
182
282
  function refreshLists() {
183
283
  for (const e of [...lists]) {
184
284
  if (!e.container.isConnected) { lists.delete(e); continue; }
185
- renderList(e.container, e.home, e.opts);
285
+ if (e.kind === 'workflows') renderWorkflowsList(e.container, e.opts);
286
+ else renderList(e.container, e.home, e.opts);
186
287
  }
187
288
  }
188
289
 
@@ -190,7 +291,12 @@
190
291
  const open = event.target.closest?.('.pg-row-open');
191
292
  if (open) { openViewer(open.dataset.home, open.dataset.page, null, open); return; }
192
293
  const del = event.target.closest?.('.pg-row-delete');
193
- if (del) deleteUnreadable(del.dataset.home, del.dataset.page, del);
294
+ if (del) { deleteUnreadable(del.dataset.home, del.dataset.page, del); return; }
295
+ const act = event.target.closest?.('.pg-wf-act');
296
+ const owner = act && [...lists].find((e) => e.kind === 'workflows' && e.container.contains(act));
297
+ if (!owner) return;
298
+ if (act.dataset.act === 'retry') void renderWorkflowsList(owner.container, owner.opts);
299
+ else owner.opts.onAction?.(act.dataset.act);
194
300
  });
195
301
 
196
302
  async function deleteUnreadable(home, id, button) {
@@ -213,7 +319,7 @@
213
319
  // ── Viewer ───────────────────────────────────────────────────────────────────────────────────────
214
320
 
215
321
  const $modal = document.getElementById('page-viewer');
216
- if (!$modal) { window.flolessPages = { renderList, open: () => {}, refresh: refreshLists }; return; }
322
+ if (!$modal) { window.flolessPages = { renderList, renderWorkflowsList, repaintWorkflowsList, open: () => {}, refresh: refreshLists }; return; }
217
323
  const $ = (id) => document.getElementById(id);
218
324
  const $title = $('pv-title');
219
325
  const $sub = $('pv-sub');
@@ -945,7 +1051,11 @@
945
1051
  } else if (st.error) {
946
1052
  kind = 'blocked';
947
1053
  text = esc(st.error.message);
948
- if (st.error.code === 'quota') actions = `<button type="button" class="ghost" data-command-id="shell.shared-links-open" data-share-act="mine">${esc('My shared links')}</button>`;
1054
+ if (st.error.code === 'quota') {
1055
+ actions = `<button type="button" class="ghost" data-command-id="shell.shared-links-open" data-share-act="mine">${esc('My shared links')}</button>`;
1056
+ // More space is a plan away, except on Enterprise (already the largest); an unknown plan is offered it too.
1057
+ if (st.error.quota?.plan !== 'enterprise') actions += `<button type="button" class="ghost" data-command-id="shell.page-share-plans" data-share-act="plans">${esc('See plans')}</button>`;
1058
+ }
949
1059
  else if (st.error.code === 'no_subscription') actions = `<button type="button" class="ghost" data-command-id="shell.page-share-plans" data-share-act="plans">${esc('See plans')}</button>`;
950
1060
  else if (st.error.code === 'share-too-large' && st.error.path) actions = `<button type="button" class="ghost" data-command-id="shell.page-share-reveal" data-share-act="reveal">${esc('Reveal in folder')}</button>`;
951
1061
  else if (['offline', 'rate_limited', 'in_progress', 'signed_out'].includes(st.error.code)) actions = `<button type="button" class="ghost" data-command-id="shell.page-share-retry" data-share-act="retry">${esc('Try again')}</button>`;
@@ -1014,7 +1124,18 @@
1014
1124
  }
1015
1125
 
1016
1126
  /** The words for a failure the server answered with, in the person's terms. */
1017
- function outcomeSentence(code) {
1127
+ // #2262 5e: the space for shared files depends on the plan (Trial 50 MB, Solo 200 MB, Enterprise 1 GB), so every
1128
+ // figure comes from floless.io's answer; nothing here knows a limit. An older floless.io names no plan.
1129
+ const PLAN_NAME = { trial: 'Trial', solo: 'Solo', enterprise: 'Enterprise' };
1130
+ const spaceSize = (b) => (b >= 1024 ** 3 ? `${+(b / 1024 ** 3).toFixed(1)} GB` : b > 0 && b < 1024 ** 2 / 2 ? 'under 1 MB' : `${Math.round(b / 1024 ** 2)} MB`);
1131
+ const spaceUsed = (q) => `${spaceSize(q.usedBytes)} of ${spaceSize(q.quotaBytes)}`;
1132
+ function quotaSentence(quota) {
1133
+ const numbers = quota ? ` (${spaceUsed(quota)}${PLAN_NAME[quota.plan] ? ` on your ${PLAN_NAME[quota.plan]} plan` : ''})` : '';
1134
+ const more = quota?.plan === 'enterprise' ? '' : ', or see plans for more space';
1135
+ return `floless.io’s space for your shared links’ files is full${numbers}, so this link wasn’t published. Revoke links you no longer need in My shared links${more}, then share again.`;
1136
+ }
1137
+
1138
+ function outcomeSentence(code, quota = null) {
1018
1139
  return ({
1019
1140
  signed_out: 'You’re signed out of FloLess, so the link wasn’t published. Sign in, then try again; FloLess keeps the request until then.',
1020
1141
  no_subscription: 'Sharing a link needs a FloLess plan, so this Page wasn’t shared. Your Page is unchanged.',
@@ -1028,7 +1149,7 @@
1028
1149
  revoked: 'This link was revoked from somewhere else, so it can’t show new versions. Share the Page again to make a new link.',
1029
1150
  not_found: 'floless.io no longer has this link. Share the Page again to make a new link.',
1030
1151
  damaged: 'One of this version’s files is damaged on this computer, so nothing was published. Share another version, or save this one again with its files.',
1031
- quota: 'floless.io’s space for your shared links’ files is full (1 GB), so this link wasn’t published. Revoke links you no longer need in My shared links, then share again.',
1152
+ quota: quotaSentence(quota),
1032
1153
  })[code] || '';
1033
1154
  }
1034
1155
 
@@ -1058,6 +1179,7 @@
1058
1179
  view.shareSeq += 1;
1059
1180
  adoptShare(body.page);
1060
1181
  view.share = { ...(view.share || {}), share: body.share, error: null };
1182
+ view.shareQuota = body.quota || null;
1061
1183
  return body.outcome;
1062
1184
  } catch (err) {
1063
1185
  if (!current()) { if (view.page?.id === id && isOpen()) void loadShare(); return null; }
@@ -1066,11 +1188,13 @@
1066
1188
  if (answer?.outcome && answer.page) {
1067
1189
  // An answer, not a failure: the share published nothing and says why (needs a plan, too large, …), with the Page's record.
1068
1190
  adoptShare(answer.page);
1191
+ view.shareQuota = answer.quota || null;
1069
1192
  view.share = { ...(view.share || {}), share: answer.share,
1070
1193
  error: answer.outcome === 'share-too-large' ? { code: 'share-too-large', message: answer.reason, path: answer.path || null } : null };
1071
1194
  return answer.outcome;
1072
1195
  }
1073
1196
  const code = err?.body?.code || 'offline';
1197
+ view.shareQuota = err?.body?.quota || null;
1074
1198
  const path = code === 'share-too-large' && (payload?.version ?? latestN()) === latestN() ? view.share?.eligibility?.path || null : null;
1075
1199
  view.share = { ...(view.share || {}), error: { code, message: err?.body?.error || outcomeSentence('offline'), path } };
1076
1200
  return null;
@@ -1155,9 +1279,10 @@
1155
1279
  } else if (outcome === 'revoke-pending') {
1156
1280
  toast('This link is being revoked, so the new version wasn’t published.', 'warn');
1157
1281
  } else if (outcome && outcome !== 'published') {
1158
- const sentence = outcomeSentence(outcome);
1282
+ const quota = outcome === 'quota' ? view.shareQuota || null : null;
1283
+ const sentence = outcomeSentence(outcome, quota);
1159
1284
  if (['no_subscription', 'too_large', 'quota', 'damaged', 'cancelled', 'reused', 'unsupported', 'revoked', 'not_found'].includes(outcome)) {
1160
- view.share = { ...(view.share || {}), error: { code: outcome, message: sentence, path: null } };
1285
+ view.share = { ...(view.share || {}), error: { code: outcome, message: sentence, path: null, quota } };
1161
1286
  paintBanner();
1162
1287
  } else if (sentence) toast(sentence, 'warn');
1163
1288
  }
@@ -1241,7 +1366,39 @@
1241
1366
  const $slNote = document.getElementById('sl-note');
1242
1367
  const $slMore = document.getElementById('sl-more');
1243
1368
  const $slClose = document.getElementById('sl-close');
1244
- const sl = { next: null, rows: [], local: [], returnFocus: null, loading: false };
1369
+ const $slUsage = document.getElementById('sl-usage');
1370
+ const $slUsageValue = document.getElementById('sl-usage-value');
1371
+ const $slMeter = document.getElementById('sl-meter');
1372
+ const $slMeterFill = document.getElementById('sl-meter-fill');
1373
+ const $slUsageStatus = document.getElementById('sl-usage-status');
1374
+ const $slPlans = document.getElementById('sl-plans');
1375
+ // `gen` numbers each list request: a refresh (after a revoke) supersedes any older answer still in flight, so a
1376
+ // late "Show more" can never repaint the space as it was before the revoke.
1377
+ const sl = { next: null, rows: [], local: [], returnFocus: null, loading: false, gen: 0 };
1378
+
1379
+ /** The space block: what is used of the plan's limit, a meter, and the way to more space (#2262 5e). */
1380
+ function slPaintUsage(usage) {
1381
+ if (!$slUsage) return;
1382
+ $slUsage.hidden = !usage;
1383
+ if (!usage) return;
1384
+ const plan = PLAN_NAME[usage.plan] || '';
1385
+ const ratio = usage.quotaBytes > 0 ? usage.usedBytes / usage.quotaBytes : 1;
1386
+ const level = ratio >= 1 ? 'full' : ratio >= 0.9 ? 'almost' : 'ok';
1387
+ const value = `${spaceUsed(usage)}${plan ? ` · ${plan} plan` : ''}`;
1388
+ const enterprise = usage.plan === 'enterprise';
1389
+ $slUsageValue.textContent = value;
1390
+ $slUsage.dataset.level = level;
1391
+ $slMeter.setAttribute('aria-valuemax', String(Math.max(usage.quotaBytes, 1)));
1392
+ $slMeter.setAttribute('aria-valuenow', String(Math.min(usage.usedBytes, Math.max(usage.quotaBytes, 1))));
1393
+ $slMeter.setAttribute('aria-valuetext', `${spaceUsed(usage)} used${plan ? `, ${plan} plan` : ''}`);
1394
+ // A little usage still shows: at least 2% of the bar once anything is stored.
1395
+ $slMeterFill.style.width = `${usage.usedBytes > 0 ? Math.max(2, Math.min(100, ratio * 100)) : 0}%`;
1396
+ $slUsageStatus.textContent = level === 'full'
1397
+ ? (enterprise ? 'Full. Revoke links you no longer need to publish again.' : 'Full. New links can’t be published until you free space or move to a larger plan.')
1398
+ : level === 'almost' ? (enterprise ? 'Almost full. Revoke links you no longer need.' : 'Almost full. Revoke links you no longer need, or see plans for more space.') : '';
1399
+ $slUsageStatus.hidden = level === 'ok';
1400
+ $slPlans.hidden = enterprise || level === 'ok';
1401
+ }
1245
1402
 
1246
1403
  const CHIP = { live: 'Live', 'pending-publish': 'Publishing', 'pending-revoke': 'Revoke waiting', revoked: 'Revoked' };
1247
1404
 
@@ -1288,12 +1445,14 @@
1288
1445
  }
1289
1446
 
1290
1447
  async function slLoad(more) {
1291
- if (sl.loading) return;
1448
+ if (more && sl.loading) return;
1449
+ const gen = ++sl.gen;
1292
1450
  sl.loading = true;
1293
1451
  $slMore.setAttribute('aria-busy', 'true');
1294
1452
  try {
1295
1453
  const q = more && sl.next ? `?before=${encodeURIComponent(sl.next)}` : '';
1296
1454
  const body = await api(`/api/pages/shared-links${q}`);
1455
+ if (gen !== sl.gen) return;
1297
1456
  if (!more) { sl.rows = []; sl.local = body.local || []; }
1298
1457
  const remote = body.remote?.ok ? body.remote.links : [];
1299
1458
  sl.next = body.remote?.ok ? body.remote.next : null;
@@ -1301,10 +1460,10 @@
1301
1460
  const tokens = new Set(sl.rows.map((r) => r.token));
1302
1461
  const localOnly = !body.remote?.ok || !sl.next ? slLocalOnly(sl.local, tokens) : [];
1303
1462
  // Slice 5: how much of the person's space for shared files is used (revoking a link frees what only it used).
1304
- const usage = body.remote?.ok ? body.remote.usage : null;
1305
- const size = (b) => (b >= 1024 ** 3 ? `${(b / 1024 ** 3).toFixed(1)} GB` : `${Math.round(b / 1024 ** 2)} MB`);
1306
- $slNote.hidden = !!body.remote?.ok && !usage;
1307
- $slNote.textContent = body.remote?.ok ? (usage ? `${usage.usedBytes >= usage.quotaBytes * 0.9 ? 'Almost full. ' : ''}Files kept on floless.io for your shared links: ${size(usage.usedBytes)} of ${size(usage.quotaBytes)}. Space a revoked link used alone is freed within a day.` : '') : (body.remote?.error === 'signed_out'
1463
+ // Signed out or offline: the note says so and no space is shown, rather than an old figure.
1464
+ slPaintUsage(body.remote?.ok ? body.remote.usage || null : null);
1465
+ $slNote.hidden = !!body.remote?.ok;
1466
+ $slNote.textContent = body.remote?.ok ? '' : (body.remote?.error === 'signed_out'
1308
1467
  ? 'You’re signed out, so FloLess can’t check floless.io. This shows the links this computer knows about. Sign in to see all of them.'
1309
1468
  : 'FloLess couldn’t reach floless.io, so this shows the links this computer knows about.');
1310
1469
  const all = [...sl.rows, ...localOnly];
@@ -1312,11 +1471,15 @@
1312
1471
  : '<p class="pg-empty sl-empty">No shared links yet. Share a Page from its viewer with the Share button.</p>';
1313
1472
  $slMore.hidden = !sl.next;
1314
1473
  } catch (err) {
1474
+ if (gen !== sl.gen) return;
1475
+ slPaintUsage(null);
1315
1476
  $slNote.hidden = false;
1316
1477
  $slNote.textContent = `FloLess couldn’t list your shared links. ${err?.body?.error || 'Try again in a moment.'}`;
1317
1478
  } finally {
1318
- sl.loading = false;
1319
- $slMore.removeAttribute('aria-busy');
1479
+ if (gen === sl.gen) {
1480
+ sl.loading = false;
1481
+ $slMore.removeAttribute('aria-busy');
1482
+ }
1320
1483
  }
1321
1484
  }
1322
1485
 
@@ -1339,6 +1502,7 @@
1339
1502
  if ($sl) {
1340
1503
  $slClose.addEventListener('click', closeSharedLinks);
1341
1504
  $slMore.addEventListener('click', () => { void slLoad(true); });
1505
+ $slPlans?.addEventListener('click', () => { window.open(PLANS_URL, '_blank', 'noopener'); });
1342
1506
  if (typeof window.onBackdropDismiss === 'function') window.onBackdropDismiss($sl, closeSharedLinks);
1343
1507
  $sl.addEventListener('keydown', (event) => {
1344
1508
  if (event.key === 'Escape') { event.stopPropagation(); closeSharedLinks(); return; }
@@ -1435,6 +1599,8 @@
1435
1599
 
1436
1600
  window.flolessPages = {
1437
1601
  renderList,
1602
+ renderWorkflowsList,
1603
+ repaintWorkflowsList,
1438
1604
  openSharedLinks: (returnFocus) => openSharedLinks(returnFocus),
1439
1605
  open: (home, id, n) => openViewer(home, id, n ?? null, document.activeElement),
1440
1606
  refresh: refreshLists,
@@ -217,6 +217,23 @@
217
217
  </li>`;
218
218
  }
219
219
 
220
+ /**
221
+ * The workflows that only belong to this project, as a note after the lists (not a list of its own): the project's
222
+ * Workflows step lists them, with their state and last run.
223
+ */
224
+ function ownedSummaryHtml(owned) {
225
+ if (!owned.length) return '';
226
+ const archived = owned.filter((w) => w.archived).length;
227
+ const active = owned.length - archived;
228
+ const what = active
229
+ ? `${plural(active, 'workflow belongs', 'workflows belong')} to this project${archived ? ` (and ${archived} archived)` : ''}. `
230
+ + `${active === 1 ? 'It is' : 'They are'} listed with ${active === 1 ? 'its' : 'their'} last run on the project’s Workflows step.`
231
+ : `${plural(archived, 'archived workflow belongs', 'archived workflows belong')} to this project. `
232
+ + `${archived === 1 ? 'It is' : 'They are'} under Archived on the project’s Workflows step.`;
233
+ return `<div class="pa-owned"><p class="pa-owned-line">${esc(what)}</p>
234
+ <button type="button" class="pa-btn" data-pa-go="workflows" data-command-id="shell.project-access-go-workflows">Show on the Workflows step</button></div>`;
235
+ }
236
+
220
237
  function group(id, title, rows, renderRow, selectable) {
221
238
  if (!rows.length) return '';
222
239
  const keys = selectable ? rows.map(selectable).filter(Boolean) : [];
@@ -257,6 +274,16 @@
257
274
  return lines.length ? `<div class="pa-note" role="status">${lines.map((line) => `<p>${esc(line)}</p>`).join('')}</div>` : '';
258
275
  }
259
276
 
277
+ // #2470 R6.7: the General projects that list this one on their Modules step. Information only: a link reaches nothing
278
+ // and gives nothing, so there is no switch — Open goes to that project.
279
+ function linkedFromHtml() {
280
+ const rows = state.data?.linkedFrom || [];
281
+ // Said when it could not be checked: no line must never be read as "no General project links this one".
282
+ if (state.data?.linkedFromUnchecked) return '<div class="pa-note pa-linked" role="note"><p>FloLess couldn’t check which General projects list this one just now. Try again in a moment.</p></div>';
283
+ if (!rows.length) return '';
284
+ return '<div class="pa-note pa-linked" role="note">' + rows.map((p) => `<p>Linked from the General project “${esc(p.name)}” <button type="button" class="pa-btn" data-pa-linked-open="${esc(p.id)}" data-command-id="shell.project-access-linked-open#${esc(p.id)}" data-command-instance-label="${esc(p.name)}" data-tip="Opens that General project on its Modules step">Open</button></p>`).join('') + '</div>';
285
+ }
286
+
260
287
  function paint() {
261
288
  $sub.textContent = `Agents, schedules and workflows that reach into “${state.project?.name || 'this project'}”.`;
262
289
  if (state.loading && !state.data) { $body.innerHTML = skeleton(); $body.setAttribute('aria-busy', 'true'); paintBar(); return; }
@@ -268,14 +295,20 @@
268
295
  }
269
296
  const agents = agentRows();
270
297
  const schedules = state.data?.schedules || [];
271
- const workflows = state.data?.workflows || [];
298
+ const all = state.data?.workflows || [];
299
+ // #2470 R6.2: where the project has a Workflows step, the workflows that only belong to it are listed there; this
300
+ // sheet says how many and links to it, and keeps listing in full what the step does not show (an Agent step on this
301
+ // project, a workflow built from its Knowledge). Without that step (the other project kinds, for now) all are listed.
302
+ const stepped = window.flolessWorkspaces?.projectHasStep?.('workflows') === true;
303
+ const ownedOnly = stepped ? all.filter((w) => w.bindings.length === 1 && w.bindings[0] === 'owner') : [];
304
+ const workflows = stepped ? all.filter((w) => !ownedOnly.includes(w)) : all;
272
305
  const notes = staleHtml() + uncheckedHtml();
273
- if (!agents.length && !schedules.length && !workflows.length && notes) {
306
+ if (!agents.length && !schedules.length && !all.length && notes) {
274
307
  // Nothing listed, but something could not be read: say that, never "nothing has access".
275
- $body.innerHTML = notes; paintBar(); return;
308
+ $body.innerHTML = linkedFromHtml() + notes; paintBar(); return;
276
309
  }
277
- if (!agents.length && !schedules.length && !workflows.length) {
278
- $body.innerHTML = `<div class="pa-empty"><p class="pa-empty-title">Nothing has access to this project yet.</p>
310
+ if (!agents.length && !schedules.length && !all.length) {
311
+ $body.innerHTML = linkedFromHtml() + `<div class="pa-empty"><p class="pa-empty-title">Nothing has access to this project yet.</p>
279
312
  <p>Add it to an Agent’s “Where it works” on the Agents tab, or schedule a workflow on it.</p>
280
313
  <div class="pa-empty-actions">
281
314
  <button type="button" class="pa-btn" data-pa-go="agents" data-command-id="shell.project-access-go-agents">Open Agents</button>
@@ -283,10 +316,11 @@
283
316
  </div></div>`;
284
317
  paintBar(); return;
285
318
  }
286
- $body.innerHTML = staleHtml() + uncheckedHtml()
319
+ $body.innerHTML = linkedFromHtml() + staleHtml() + uncheckedHtml()
287
320
  + group('agents', 'Agents that can work here', agents, agentRow, (r) => (switchable(r) ? keyOf('agent', r.agentId) : null))
288
321
  + group('schedules', 'Schedules that run on this project', schedules, scheduleRow, (s) => (s.broken ? null : keyOf('schedule', s.routineId)))
289
- + group('workflows', 'Workflows that use it', workflows, workflowRow, null);
322
+ + group('workflows', 'Workflows that use it', workflows, workflowRow, null)
323
+ + ownedSummaryHtml(ownedOnly);
290
324
  paintBar();
291
325
  // A repaint replaces the control that had focus; keep focus inside the sheet so Escape and Tab still work there.
292
326
  if (isOpen() && (!document.activeElement || document.activeElement === document.body)) $panel?.focus();
@@ -431,7 +465,12 @@
431
465
  state.selected.clear(); state.confirm = null; state.rowError.clear(); state.turnedOff.clear();
432
466
  const target = state.returnFocus;
433
467
  state.returnFocus = null;
434
- if (target && document.contains(target)) target.focus();
468
+ // The control that opened the sheet may have been redrawn meanwhile (a list re-read): find it again by its Instructor
469
+ // id, else the chip, so focus never drops to the page.
470
+ const id = target?.getAttribute?.('data-command-id');
471
+ const again = target && document.contains(target) ? target
472
+ : (id && [...document.querySelectorAll('[data-command-id]')].find((el) => el.getAttribute('data-command-id') === id)) || ($chip.hidden ? null : $chip);
473
+ again?.focus?.();
435
474
  }
436
475
 
437
476
  async function openItem(key) {
@@ -522,8 +561,28 @@
522
561
  if (el.hasAttribute('data-pa-clear')) { state.selected.clear(); state.confirm = null; paint(); return; }
523
562
  if (el.dataset.paOpen) { void openItem(el.dataset.paOpen); return; }
524
563
  if (el.hasAttribute('data-pa-retry')) { void load(); return; }
564
+ if (el.dataset.paLinkedOpen) {
565
+ const generalId = el.dataset.paLinkedOpen;
566
+ close();
567
+ void Promise.resolve(window.flolessWorkspaces?.openModulesStep?.(generalId)).catch((error) => {
568
+ console.warn('[project-access] the General project could not be opened', error);
569
+ toast('FloLess couldn’t open that General project. Open it from Workspaces.', 'warn');
570
+ });
571
+ return;
572
+ }
525
573
  if (el.dataset.paGo === 'agents') { close(); void window.flolessWorkspaces?.setMode?.('agents'); return; }
526
574
  if (el.dataset.paGo === 'routines') { close(); if (typeof openRoutines === 'function') openRoutines(); }
575
+ if (el.dataset.paGo === 'workflows') {
576
+ const projectId = state.project?.id;
577
+ close();
578
+ void Promise.resolve(window.flolessWorkspaces?.openWorkflowsStep?.(projectId)).then(() => {
579
+ // The keyboard lands where the person was sent: the step's heading.
580
+ document.querySelector('#ws-workflows [data-pw-heading]')?.focus?.();
581
+ }).catch((error) => {
582
+ console.warn('[project-access] the Workflows step could not be opened', error);
583
+ toast('FloLess couldn’t open this project’s Workflows step. Open the project and choose Workflows.', 'warn');
584
+ });
585
+ }
527
586
  });
528
587
 
529
588
  // Something else changed the projects or the workflows: the chip (and an open sheet) read again.