@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/aware.js CHANGED
@@ -22,6 +22,8 @@
22
22
  const $kbDriftChip = document.getElementById('kb-drift-chip');
23
23
  const $reportModal = document.getElementById('report-modal');
24
24
  const $reportFrame = document.getElementById('report-frame');
25
+ const $reportFramePage = document.getElementById('report-frame-page'); // #2476: the saved Page version of a report with files
26
+ const $reportFilesNote = document.getElementById('report-files-note');
25
27
  const $reportFrame3d = document.getElementById('report-frame-3d');
26
28
  const $reportOverlay = document.getElementById('report-overlay');
27
29
  const $reportTitle = document.getElementById('report-title');
@@ -1943,7 +1945,8 @@
1943
1945
  .map((project) => ({
1944
1946
  value: `project:${project.id}`,
1945
1947
  label: project.name || project.id,
1946
- meta: `${project.templateId || project.app || 'Workspace'} project`,
1948
+ // #2470 R6.2: a General project is named as the person sees it, never by FloLess's type id.
1949
+ meta: (project.templateId || project.app) === 'floless-general' ? 'General project' : `${project.templateId || project.app || 'Workspace'} project`,
1947
1950
  })),
1948
1951
  ];
1949
1952
  }
@@ -1980,6 +1983,10 @@
1980
1983
  try {
1981
1984
  const { projects = [] } = await api('/api/projects');
1982
1985
  const ownerOptions = workflowOwnerOptions(projects);
1986
+ const wantedOwner = typeof prefill.ownerProjectId === 'string' && prefill.ownerProjectId ? `project:${prefill.ownerProjectId}` : null;
1987
+ const preselectedOwner = wantedOwner && ownerOptions.some((o) => o.value === wantedOwner) ? wantedOwner : 'standalone';
1988
+ // The project may have been archived meanwhile: the dialog still opens, on Standalone, and says why.
1989
+ if (wantedOwner && preselectedOwner !== wantedOwner) showToast('That project isn’t in the Location list any more, so the new workflow starts as Standalone. Choose its location in the dialog.', 'warn');
1983
1990
  const result = await formModal({
1984
1991
  title: guide ? 'Build this workflow' : 'Start a workflow',
1985
1992
  sub: 'Choose where it belongs. Its files, chat, history and AI working folder stay with that location.',
@@ -1991,7 +1998,8 @@
1991
1998
  ...(typeof prefill.name === 'string' && prefill.name ? { value: prefill.name } : {}),
1992
1999
  },
1993
2000
  {
1994
- name: 'owner', label: 'Location', type: 'select', value: 'standalone',
2001
+ // #2470 R6.2: opened from a project's Workflows step, the project is already chosen (the person can change it).
2002
+ name: 'owner', label: 'Location', type: 'select', value: preselectedOwner,
1995
2003
  commandId: 'shell.new-workflow-location', options: ownerOptions,
1996
2004
  },
1997
2005
  ...(guide ? [] : [{
@@ -2535,7 +2543,12 @@
2535
2543
  let wsTitleLanding = false; // explicit because a project may itself be named "Workspaces"
2536
2544
  let wsTitleProjectId = null; // identity: two projects may legitimately share a display name
2537
2545
  // #1890: on the Workflows landing the tab is named after it, not after the workflow still loaded underneath.
2538
- const syncTabTitle = () => { document.title = tabTitle(wsTitleName || (wfLanding ? 'Workflows' : null), wfTitleText); };
2546
+ // The tab signal (web/tab-signal.js) leads the title with how a run is going; aware.js stays its one writer.
2547
+ const syncTabTitle = () => {
2548
+ const lead = window.flolessTabSignal ? window.flolessTabSignal.prefix() : '';
2549
+ document.title = lead + tabTitle(wsTitleName || (wfLanding ? 'Workflows' : null), wfTitleText);
2550
+ };
2551
+ if (window.flolessTabSignal) window.flolessTabSignal.onChange(syncTabTitle);
2539
2552
  function setComboTriggerLabel(text) {
2540
2553
  if ($wfTriggerLabel) $wfTriggerLabel.textContent = text || 'select workflow';
2541
2554
  wfTitleText = text || '';
@@ -4159,6 +4172,33 @@
4159
4172
  const workflowPageLatest = new Map(); // app id → { home, pageId, version, at }
4160
4173
  const WORKFLOW_PAGE_RUNS_KEPT = 64;
4161
4174
 
4175
+ // #2476: the run viewer's view of a report that carries files — the inert copy and a plain note while its Page version is
4176
+ // being saved, then that version's own isolated frame once it says it is ready. Its state comes from the server's answer
4177
+ // about this exact run (web/run-page-view.js); this file only feeds it the report on screen, the news, and the end of a view.
4178
+ const runPageView = window.FlolessRunPageView.create({
4179
+ api, inert: $reportFrame, page: $reportFramePage, note: $reportFilesNote, win: window,
4180
+ currentApp: () => currentId,
4181
+ // A lookup that found the version: the header's "Version N · Open in Pages" learns it even if the news was missed.
4182
+ onSaved: ({ app, runId, fire, home, pageId, version }) => {
4183
+ const key = captureKeyOf(runId, fire);
4184
+ if (!key) return;
4185
+ const known = workflowPageByRun.get(key);
4186
+ if (known && known.version >= version) return;
4187
+ workflowPageByRun.set(key, { app, home, pageId, version });
4188
+ if (workflowPageByRun.size > WORKFLOW_PAGE_RUNS_KEPT) workflowPageByRun.delete(workflowPageByRun.keys().next().value);
4189
+ noteWorkflowPageLatest(app, { home, pageId, version });
4190
+ if (currentId === app) paintReportPageLinks();
4191
+ },
4192
+ });
4193
+ // A workspace switch: what this window knows about saved versions belongs to the old workspace.
4194
+ let runPageRoot = null;
4195
+ window.addEventListener('floless:workspace-root-state', (event) => {
4196
+ const root = event.detail && event.detail.root;
4197
+ const id = root ? `${root.rootId}#${root.generation}` : null;
4198
+ if (runPageRoot !== null && id !== runPageRoot) { runPageView.reset(); workflowPageByRun.clear(); paintReportPageLinks(); }
4199
+ runPageRoot = id;
4200
+ });
4201
+
4162
4202
  function noteWorkflowPageLatest(app, page) {
4163
4203
  const prev = workflowPageLatest.get(app);
4164
4204
  if (prev && prev.home === page.home && prev.pageId === page.pageId && prev.version >= page.version) return;
@@ -4173,6 +4213,7 @@
4173
4213
 
4174
4214
  function applyWorkflowPageCaptured(m) {
4175
4215
  if (!m || typeof m.app !== 'string' || typeof m.runId !== 'string') return;
4216
+ runPageView.onNews(m); // #2476: a report with files on screen follows its own capture
4176
4217
  if (typeof m.warning === 'string') {
4177
4218
  // The run itself succeeded and its report is shown; the window on this workflow is told, the others log it.
4178
4219
  if (currentId === m.app) showToast(m.warning, 'warn');
@@ -4453,6 +4494,8 @@
4453
4494
  }
4454
4495
  /** Show one section of a saved complete report. Resolves true once it is on screen, false when it is not. */
4455
4496
  async function paintCompleteReport(report, asked = null, busyUntil = null) {
4497
+ runPageView.invalidate(); // #2476: another view replaces a report-with-files view
4498
+ $reportFrame.hidden = false;
4456
4499
  // #2539: a report another read holds is waited for, not failed — right after a run that is the workflow's Page
4457
4500
  // saving its copy, which reads the whole report. Past this wait the viewer offers Try again instead.
4458
4501
  const REPORT_BUSY_WAIT_MS = 5 * 60_000;
@@ -4598,13 +4641,14 @@
4598
4641
  // origin, cannot touch the app page) and keeps a "Loading 3D view…" overlay until the doc
4599
4642
  // posts `viewer-ready`. Exactly one frame is shown at a time.
4600
4643
  function paintReport(html, interactive, entry = null) {
4644
+ runPageView.invalidate(); // #2476: a new paint ends the previous report's Page frame, its lookups and its timers
4601
4645
  clearCompleteReportView();
4602
4646
  $reportOpen.hidden = false;
4603
4647
  lastPaintedHtml = html || '';
4604
4648
  lastPaintedInteractive = !!interactive; // drives the share copy: a 3D model is not a "frozen report"
4605
4649
  showSavedPathActions(''); // default off; the caller re-shows if this report saved a file
4606
4650
  if ($reportPage) $reportPage.hidden = true; // likewise its Page link (paintReportPageLinks, once it is cached)
4607
- if (!interactive && entry && entry.withFiles) { paintReportWithFiles(html); return; }
4651
+ if (!interactive && entry && entry.withFiles) { paintReportWithFiles(html, entry); return; }
4608
4652
  if (interactive) {
4609
4653
  $reportFrame.hidden = true; $reportFrame.srcdoc = '';
4610
4654
  $reportFrame3d.hidden = false;
@@ -4624,25 +4668,26 @@
4624
4668
  }
4625
4669
  }
4626
4670
 
4627
- // #2262 slice 3c: a report that carries files (`report_folder`) refers to them as `assets/…`, which resolve only in its
4628
- // Page version. The run viewer shows a copy with those references made inert (web/report-files.js: no broken picture,
4629
- // no failed request) and a note pointing to the Page version, where the files are ("Open in Pages" appears once it is
4630
- // saved). Open and Share are hidden here: they would hand out this copy without its files — the Page has its own Share.
4631
- // (A viewer that switches to the saved version itself was split out on the night shift — Fable, review stop signal.)
4632
- const FILES_NOTE = 'This report has pictures and files that only show in its Page version. Use “Open in Pages” at the top to see it with them.';
4633
- function paintReportWithFiles(html) {
4671
+ // #2262 slice 3c / #2476: a report that carries files (`report_folder`) refers to them as `assets/…`, which resolve only in
4672
+ // its Page version. `html` is the inert copy the SERVER made (nothing asks FloLess for a missing file); the controller
4673
+ // (web/run-page-view.js) says what is happening to the version and shows it in its own isolated frame once it is ready.
4674
+ // Open and Share stay hidden in every state of this view: they would hand out the copy without its files — the Page has
4675
+ // its own Share, and "Version N · Open in Pages" is the way out.
4676
+ function paintReportWithFiles(html, entry) {
4634
4677
  $reportFrame3d.hidden = true; $reportFrame3d.removeAttribute('src');
4635
4678
  $reportFrame.hidden = false;
4636
- $reportFrame.srcdoc = window.FlolessReportFiles.neutralize(html, null, FILES_NOTE);
4679
+ $reportFrame.srcdoc = html;
4637
4680
  $reportOverlay.hidden = true; $reportOverlay.replaceChildren();
4638
4681
  $reportOpen.hidden = true;
4639
4682
  $reportShare.hidden = true;
4683
+ runPageView.paint(entry);
4640
4684
  }
4641
4685
 
4642
4686
  // Reset the viewer to "no report shown": clear BOTH frames + the Open buffer, so a stale
4643
4687
  // interactive 3D doc can't linger (its WebGL loop running) behind an overlay, and ↗ Open
4644
4688
  // can't reopen a previous app's report. Used by every empty / transition state.
4645
4689
  function clearReportFrames() {
4690
+ runPageView.invalidate(); // #2476
4646
4691
  clearCompleteReportView();
4647
4692
  $reportOpen.hidden = false;
4648
4693
  $reportFrame.srcdoc = ''; $reportFrame.hidden = false;
@@ -6588,6 +6633,7 @@
6588
6633
 
6589
6634
  async function closeReportViewer() {
6590
6635
  hideModal($reportModal);
6636
+ runPageView.invalidate(); // #2476: nothing about a report with files keeps running behind a closed viewer
6591
6637
  reportSectionRequest += 1; // #2539: a section still waiting for a busy report stops asking once the viewer closes
6592
6638
  const routineId = viewingScheduledReportRoutine;
6593
6639
  viewingScheduledReportRoutine = null;
@@ -10783,8 +10829,9 @@
10783
10829
  // workflow this tab shows that someone else started is followed read-only (no Stop).
10784
10830
  // #2241: a run that FAILED after an Agent answered ends with run-finished, not run-ended: its AI record is read then too.
10785
10831
  if (m.type === 'run-finished' && m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id);
10832
+ signalRunEvent(m); // the browser tab hears its run's ending even when the strip already settled
10786
10833
  if (liveRunOwns(m)) {
10787
- if (m.type === 'run-live') { if (m.runId) liveRun.runId = m.runId; }
10834
+ if (m.type === 'run-live') { if (m.runId) { liveRun.runId = m.runId; signalRunNote(liveRun); } }
10788
10835
  else if (m.type === 'node-progress') onLiveProgress(m);
10789
10836
  else finishLiveRun(typeof m.outcome === 'string' ? m.outcome : 'failed');
10790
10837
  } else if (m.id === currentId && !(liveRun && liveRun.owner && !liveRun.ended)) {
@@ -10986,6 +11033,8 @@
10986
11033
  } else if (m.type === 'run-ended') {
10987
11034
  // Panel data bindings (last-run-output/-status) go stale after any run.
10988
11035
  if (window.flolessPanels) window.flolessPanels.refreshData();
11036
+ // #2470 R6.2: a project's Workflows step shows each workflow's last run; it re-reads only while on screen.
11037
+ window.flolessProjectWorkflows?.refresh?.();
10989
11038
  if (m.id && m.id === currentId) void globalThis.flolessAgentSteps?.refreshRunRecord(m.id); // #2241 S5
10990
11039
  } else if (m.type === 'routine-changed') {
10991
11040
  loadRoutinesData();
@@ -11003,6 +11052,7 @@
11003
11052
  if ($routinesModal.classList.contains('show')) renderRoutinesList();
11004
11053
  } else if (m.type === 'routine-run-ended') {
11005
11054
  runningRoutines.delete(m.id);
11055
+ window.flolessProjectWorkflows?.refresh?.(); // #2470 R6.2, as run-ended
11006
11056
  loadRoutinesData();
11007
11057
  if (window.flolessPanels) window.flolessPanels.refreshData(); // routine runs also refresh bindings
11008
11058
  window.flolessAgents?.refreshRuns?.(); // #2035: an open agent page shows the run its routine just started
@@ -13061,7 +13111,7 @@
13061
13111
  // One path for a question and a change, so a waiting message is never labelled a suggestion.
13062
13112
  return r.instructorContext.commandId === 'filter.ask-ai-change' ? 'filter answer' : 'filter question';
13063
13113
  if (r.type === 'revision-read') return (!r.baseVersion || r.baseVersion <= 0) ? 'initial drawing read' : 'updated drawing read';
13064
- return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
13114
+ return r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : r.type === 'knowledge-consult' ? 'knowledge' : r.type === 'project-kickoff' ? 'kickoff' : r.type === 'tweak-contract' ? 'contract' : 'tweak';
13065
13115
  }
13066
13116
 
13067
13117
  function isInitialDrawingRead(r) {
@@ -15216,6 +15266,16 @@
15216
15266
  window.dispatchEvent(new CustomEvent('floless:revit-capability-changed'));
15217
15267
  });
15218
15268
 
15269
+ // And Steel Model's, under its own name.
15270
+ window.addEventListener('floless:open-steel-model-access', async (event) => {
15271
+ if (event.detail?.state === 'account-selection-required') {
15272
+ await recheckLicenseAndGate({ forRevitAccountSelection: true, moduleLabel: 'Steel Model' });
15273
+ } else {
15274
+ await recheckLicenseAndGate();
15275
+ }
15276
+ window.dispatchEvent(new CustomEvent('floless:revit-capability-changed'));
15277
+ });
15278
+
15219
15279
  function runtimeSectionSummary(runtimes, active, folder) {
15220
15280
  // What FloLess would LAUNCH (#1622): its own copy where it runs one, else the user's install.
15221
15281
  const installed = runtimes.filter(runtimeCopyInstalled);
@@ -15554,7 +15614,13 @@
15554
15614
  let state = 'Unavailable in AI Chat';
15555
15615
  let stateClass = 'is-chat-unavailable';
15556
15616
  let why;
15557
- if (!supported) { state = 'Not available in AI Chat'; why = 'AI Chat can’t use this integration yet.'; }
15617
+ // #2620: AI Chat runs any connected tool's commands with this account (tools.read / tools.change), so a service
15618
+ // without the older per-chat account picker is still usable in chat: its state follows the sign-in alone.
15619
+ if (!supported) {
15620
+ if (slot.status === 'valid') { state = 'Ready for AI Chat'; stateClass = 'is-chat-ready'; why = 'AI Chat uses this account when it runs this tool’s commands.'; }
15621
+ else if (slot.status === 'expired') { state = 'Reconnect for AI Chat'; stateClass = 'is-chat-warning'; why = 'This account’s sign-in has expired. Reconnect it to use it in AI Chat.'; }
15622
+ else why = 'Connect this account to use it in AI Chat.';
15623
+ }
15558
15624
  else if (ready) { state = 'Ready for AI Chat'; stateClass = 'is-chat-ready'; why = 'This verified account can be selected in AI Chat.'; }
15559
15625
  else if (slot.status === 'expired') { state = 'Reconnect for AI Chat'; stateClass = 'is-chat-warning'; why = 'This account’s sign-in has expired. Reconnect it to use it in AI Chat.'; }
15560
15626
  else if (slot.status !== 'valid') { state = 'Connect for AI Chat'; stateClass = 'is-chat-warning'; }
@@ -16364,7 +16430,7 @@
16364
16430
  if (!m || !m.workflow || typeof m.html !== 'string') return;
16365
16431
  const runId = typeof m.runId === 'string' ? m.runId : null;
16366
16432
  const entry = { nodeId: m.nodeId || null, label: 'live · on selection change', html: m.html,
16367
- runId, captureKey: captureKeyOf(runId, m.fireKey), withFiles: m.withFiles === true };
16433
+ runId, captureKey: captureKeyOf(runId, m.fireKey), fireKey: typeof m.fireKey === 'string' ? m.fireKey : null, withFiles: m.withFiles === true };
16368
16434
  lastReportByApp.set(m.workflow, entry);
16369
16435
  const open = $reportModal && $reportModal.classList.contains('show');
16370
16436
  if (!open || currentId !== m.workflow || reportRunning) return;
@@ -16544,8 +16610,10 @@
16544
16610
  syncRunStrip();
16545
16611
  }
16546
16612
 
16547
- function disposeLiveRun() {
16613
+ function disposeLiveRun({ keepSignal = false } = {}) {
16548
16614
  if (!liveRun) return;
16615
+ // A run let go before its ending takes the tab signal along; a video offer keeps it for the ending to come.
16616
+ if (!liveRun.ended && !keepSignal && signalRunIs(liveRun)) signalRunDrop();
16549
16617
  if (liveRun.showTimer) clearTimeout(liveRun.showTimer);
16550
16618
  if (liveRun.lingerTimer) clearTimeout(liveRun.lingerTimer);
16551
16619
  if (liveRun.view) liveRun.view.destroy();
@@ -16562,6 +16630,7 @@
16562
16630
  const token = newRunToken();
16563
16631
  rememberRunToken(appId, token);
16564
16632
  liveRun = { appId, token, runId: null, owner: true, surface, view: null, shown: false, showTimer: null, lingerTimer: null, ended: false, startedAt: Date.now() };
16633
+ signalRunBegin(liveRun);
16565
16634
  if (surface === 'overlay' && overlayHost && window.flolessRunProgressView) {
16566
16635
  liveRun.view = window.flolessRunProgressView.create({ size: 40, hat: true, fallbackHeadline, stop: null });
16567
16636
  overlayHost.append(liveRun.view.root);
@@ -16572,6 +16641,55 @@
16572
16641
  return token;
16573
16642
  }
16574
16643
 
16644
+ // ── tab signal (begin) — lifted by server/tab-signal-ui.test.ts; keep it self-contained.
16645
+ // The browser tab follows the run too (web/tab-signal.js), so a person working in Tekla sees it end. It follows
16646
+ // the RUN, by its token and run id, not the liveRun view: a video offer can replace that view before the run's
16647
+ // own ending arrives, and the tab must still hear that ending.
16648
+ let signalRun = null; // { run, token, runId }
16649
+ function signalRunBegin(run) {
16650
+ if (!window.flolessTabSignal) return;
16651
+ signalRun = { run, token: run.token || null, runId: run.runId || null };
16652
+ const app = apps.get(run.appId);
16653
+ window.flolessTabSignal.begin((app && app.displayName) || run.appId, run.startedAt);
16654
+ }
16655
+ function signalRunIs(r) {
16656
+ if (!signalRun || !r) return false;
16657
+ return r === signalRun.run || !!(r.token && r.token === signalRun.token) || !!(r.runId && r.runId === signalRun.runId);
16658
+ }
16659
+ /** The run learned its id (run-live, node-progress): the tab can now match its ending by it. */
16660
+ function signalRunNote(run) {
16661
+ if (signalRun && run && run.runId && signalRunIs(run)) signalRun.runId = run.runId;
16662
+ }
16663
+ function signalRunEnd(outcome) {
16664
+ if (!signalRun) return;
16665
+ const { runId } = signalRun;
16666
+ signalRun = null;
16667
+ if (window.flolessTabSignal) window.flolessTabSignal.finish(outcome, runId);
16668
+ }
16669
+ function signalRunDrop() {
16670
+ if (!signalRun) return;
16671
+ signalRun = null;
16672
+ if (window.flolessTabSignal) window.flolessTabSignal.cancel();
16673
+ }
16674
+ function signalRunOwns(m) {
16675
+ return !!(signalRun && m && ((m.clientRunToken && m.clientRunToken === signalRun.token) || (m.runId && m.runId === signalRun.runId)));
16676
+ }
16677
+ /** Every run event the server sends, before the liveRun view decides whether it is still its own. */
16678
+ function signalRunEvent(m) {
16679
+ if (!signalRunOwns(m)) return;
16680
+ if (m.runId) signalRun.runId = m.runId;
16681
+ if (m.type !== 'run-finished') return;
16682
+ // The ending can beat this tab's own Run answer after a video offer settled the strip: the saved token goes
16683
+ // now either way, so a reload never rediscovers a finished run.
16684
+ if (signalRun.token) forgetRunToken(signalRun.token);
16685
+ signalRunEnd(typeof m.outcome === 'string' ? m.outcome : 'failed');
16686
+ }
16687
+ /** A progress record reaches the tab only when it is the followed run's own (another workflow's is not). */
16688
+ function signalRunProgress(m) {
16689
+ if (signalRunOwns(m) && window.flolessTabSignal) window.flolessTabSignal.progress(m);
16690
+ }
16691
+ // ── tab signal (end)
16692
+
16575
16693
  function liveRunOwns(m) {
16576
16694
  if (!liveRun || liveRun.ended) return false;
16577
16695
  if (m.clientRunToken && m.clientRunToken === liveRun.token) return true;
@@ -16580,9 +16698,10 @@
16580
16698
 
16581
16699
  function onLiveProgress(m) {
16582
16700
  if (!liveRun) return;
16583
- if (m.runId && !liveRun.runId) liveRun.runId = m.runId;
16701
+ if (m.runId && !liveRun.runId) { liveRun.runId = m.runId; signalRunNote(liveRun); }
16584
16702
  if (liveRun.surface === 'strip' && !liveRun.shown) showRunStrip();
16585
16703
  if (liveRun.view) liveRun.view.apply(m);
16704
+ signalRunProgress(m);
16586
16705
  if (liveRun.appId === currentId) setNodeProgress(m.node, m);
16587
16706
  }
16588
16707
 
@@ -16606,8 +16725,11 @@
16606
16725
  const appName = (apps.get(appId) && apps.get(appId).displayName) || appId;
16607
16726
  let run = liveRun && liveRun.appId === appId && liveRun.surface === 'strip' ? liveRun : null;
16608
16727
  if (!run || !run.view) {
16609
- disposeLiveRun();
16610
- liveRun = { appId, token: null, runId: null, owner: true, surface: 'strip', view: null, shown: false, showTimer: null, lingerTimer: null, ended: false, startedAt: Date.now() };
16728
+ // The videos can arrive before the run's own ending: the offer keeps the run's identity, so the tab signal
16729
+ // still hears that ending (signalRunEvent, or this tab's own Run answer through finishLiveRun).
16730
+ const prior = liveRun && !liveRun.ended ? liveRun : null;
16731
+ disposeLiveRun({ keepSignal: !!prior });
16732
+ liveRun = { appId, token: prior ? prior.token : null, runId: prior ? prior.runId : null, owner: true, surface: 'strip', view: null, shown: false, showTimer: null, lingerTimer: null, ended: false, startedAt: Date.now() };
16611
16733
  showRunStrip();
16612
16734
  run = liveRun;
16613
16735
  run.view.finish('ok');
@@ -16640,9 +16762,16 @@
16640
16762
 
16641
16763
  function finishLiveRun(outcome) {
16642
16764
  if (pageLeaving) return; // the page is going away mid-run: keep the token so the next page resumes it
16765
+ if (liveRun && liveRun.ended && signalRunIs(liveRun)) {
16766
+ // Its videos came first and settled the strip; this is the ending the tab was still waiting for.
16767
+ forgetRunToken(liveRun.token);
16768
+ signalRunEnd(outcome);
16769
+ return;
16770
+ }
16643
16771
  if (!liveRun || liveRun.ended) return;
16644
16772
  const run = liveRun;
16645
16773
  run.ended = true;
16774
+ if (signalRunIs(run)) signalRunEnd(outcome);
16646
16775
  forgetRunToken(run.token);
16647
16776
  syncRunControls();
16648
16777
  if (run.showTimer) { clearTimeout(run.showTimer); run.showTimer = null; }
@@ -16698,6 +16827,7 @@
16698
16827
  if (liveRun && !liveRun.ended) return;
16699
16828
  disposeLiveRun();
16700
16829
  liveRun = { appId: m.id, token: m.clientRunToken || null, runId: m.runId || null, owner: false, surface: 'strip', view: null, shown: false, showTimer: null, lingerTimer: null, ended: false, startedAt: typeof m.startedAt === 'number' ? m.startedAt : Date.now() };
16830
+ signalRunBegin(liveRun);
16701
16831
  liveRun.showTimer = setTimeout(showRunStrip, RUN_STRIP_DELAY_MS);
16702
16832
  }
16703
16833
 
@@ -16793,6 +16923,7 @@
16793
16923
  }
16794
16924
  disposeLiveRun();
16795
16925
  liveRun = { appId: snap.id, token: saved.token, runId: snap.runId, runRequestId: typeof snap.runRequestId === 'string' ? snap.runRequestId : null, owner: true, surface: 'strip', view: null, shown: false, showTimer: null, lingerTimer: null, ended: false, startedAt: snap.startedAt };
16926
+ signalRunBegin(liveRun); // a reload mid-run: the tab says it is still going
16796
16927
  showRunStrip();
16797
16928
  for (const rec of snap.nodes || []) onLiveProgress({ ...rec, runId: snap.runId });
16798
16929
  }
@@ -16826,7 +16957,7 @@
16826
16957
  // revert to the last cached report if there is one, else an idle prompt.
16827
16958
  function clearTriggerCollecting() {
16828
16959
  const cached = currentId && lastReportByApp.get(currentId);
16829
- if (cached && cached.html) { paintReport(cached.html); return; }
16960
+ if (cached && cached.html) { paintReport(cached.html, cached.interactive, cached); return; }
16830
16961
  $reportOverlay.replaceChildren();
16831
16962
  $reportOverlay.hidden = false;
16832
16963
  $reportOverlay.append(mkEl('div', null, 'Listening for the next selection…'));
@@ -16875,7 +17006,7 @@
16875
17006
  $reportTitle.textContent = `HTML Viewer · ${app.displayName}`;
16876
17007
  $reportModal.dataset.nodeId = reportNodeId() || '';
16877
17008
  const cached = lastReportByApp.get(id);
16878
- if (cached && cached.html) paintReport(cached.html);
17009
+ if (cached && cached.html) paintReport(cached.html, cached.interactive, cached);
16879
17010
  else { clearReportFrames(); $reportShare.hidden = true; }
16880
17011
  $reportOverlay.hidden = false;
16881
17012
  $reportOverlay.replaceChildren();
@@ -16968,7 +17099,7 @@
16968
17099
  if (cached && cached.html) {
16969
17100
  $reportOverlay.hidden = true;
16970
17101
  $reportOverlay.replaceChildren();
16971
- $reportShare.hidden = false; // the cached report is the primary content
17102
+ $reportShare.hidden = !!cached.withFiles && !cached.interactive; // the cached report is the primary content (a report with files is not shared from here)
16972
17103
  $reportSub.innerHTML = `<span class="live-pip" aria-hidden="true"></span>Live · waiting for the next change — change your selection in Tekla to refresh the report.`;
16973
17104
  } else {
16974
17105
  clearReportFrames();
@@ -16993,7 +17124,7 @@
16993
17124
  if (cached && cached.html) {
16994
17125
  $reportOverlay.hidden = true;
16995
17126
  $reportOverlay.replaceChildren();
16996
- $reportShare.hidden = false;
17127
+ $reportShare.hidden = !!cached.withFiles && !cached.interactive;
16997
17128
  $reportSub.innerHTML = complete
16998
17129
  ? `Run complete · last report above — click <strong>▶ Run workflow</strong> to run again.`
16999
17130
  : `Live session stopped · last report above — click <strong>▶ Run workflow</strong> to start again.`;
@@ -18607,6 +18738,10 @@
18607
18738
  if (selectionTicket === selectionAtStart) selectionTicket += 1;
18608
18739
  const committed = { ...row, ...workflow, restoreRefreshState: 'pending' };
18609
18740
  wfOwned = wfOwned.filter((item) => item.workflowId !== workflowId).concat(committed);
18741
+ // It lands in Your workflows: open that section now, so the restored card and its "Refreshing…" line show at once
18742
+ // rather than only after the list refresh, however long that takes.
18743
+ const yours = $wfLanding?.querySelector('.wf-section[data-wf-section="yours"]');
18744
+ if (yours) yours.open = true;
18610
18745
  if (wfLanding) renderWorkflowsLanding();
18611
18746
  let refreshFailed = false;
18612
18747
  try { await loadApps({ preserveSelection: true }); }
@@ -18631,6 +18766,9 @@
18631
18766
  ? $wfLanding.querySelector(`[data-wf-restored="${CSS.escape(workflowId)}"]`)
18632
18767
  || $wfLanding.querySelector(publication ? `[data-wf-id="${CSS.escape(publication.id)}"]` : `[data-wf-draft="${CSS.escape(workflowId)}"]`)
18633
18768
  : $wfLanding.querySelector(`[data-wf-restore="${CSS.escape(workflowId)}"]`);
18769
+ // A card in a section the person closed cannot take focus: open its section first.
18770
+ const section = target?.closest('.wf-section');
18771
+ if (section && !section.open) section.open = true;
18634
18772
  (target && !target.hidden ? target : document.getElementById('wf-landing-title'))?.focus();
18635
18773
  }
18636
18774
  }
@@ -18641,6 +18779,10 @@
18641
18779
  const $wfLanding = document.getElementById('wf-landing');
18642
18780
  // The landing search's query, kept outside the input because the landing re-renders with innerHTML.
18643
18781
  let wfLandingQuery = '';
18782
+ // #2568: the landing's two tabs. The choice is remembered by this browser window; anything unknown, or a store that
18783
+ // throws (private window, blocked site data), reads as Workflows.
18784
+ const WF_TAB_KEY = 'floless.workflowsLandingTab';
18785
+ let wfLandingTab = (() => { try { return localStorage.getItem(WF_TAB_KEY) === 'pages' ? 'pages' : 'workflows'; } catch { return 'workflows'; } })();
18644
18786
  function showWorkflowsLanding(on) {
18645
18787
  const next = Boolean(on);
18646
18788
  if (next === wfLanding && (!next || $wfLanding?.childElementCount)) { if (next) renderWorkflowsLanding(); return; }
@@ -18690,19 +18832,75 @@
18690
18832
  + `Your other workflows are not affected. Ask AI Chat to repair or reinstall ${one ? 'it' : 'them'}.</div>`;
18691
18833
  }
18692
18834
 
18835
+ /** The Workflows landing's heading, sub line, tabs and (when there is something to search) search box, shared by both tabs. */
18836
+ function workflowsLandingHeadHtml(esc, showSearch) {
18837
+ const pages = wfLandingTab === 'pages';
18838
+ const tab = (id, label) => `<button type="button" role="tab" id="wf-tab-${id}" data-wf-tab="${id}" class="${wfLandingTab === id ? 'active' : ''}"`
18839
+ + ` aria-selected="${wfLandingTab === id}"${id === 'pages' ? ' aria-controls="wf-pages-panel"' : ''} tabindex="${wfLandingTab === id ? 0 : -1}"`
18840
+ + ` data-command-id="shell.workflows-landing-tab#${esc(id)}">${label}</button>`;
18841
+ return `<div class="ws-head"><div class="ws-head-text"><h2 tabindex="-1" id="wf-landing-title">Workflows</h2>`
18842
+ + `<p class="ws-sub">Build, run and manage the workflows behind your projects. Ask AI Chat on the left to build one with you.</p>`
18843
+ + `<div class="tabs ws-step-tabs wf-landing-tabs" role="tablist" aria-label="Workflows page">${tab('workflows', 'Workflows')}${tab('pages', 'Pages')}</div></div>`
18844
+ + (showSearch ? `<div class="ws-head-actions"><input type="search" id="wf-landing-search" class="ws-landing-search" data-command-id="shell.workflows-landing-search" placeholder="${pages ? 'Search pages' : 'Search workflows'}" aria-label="${pages ? 'Search Pages by workflow, Page title or project' : 'Search workflows by name, project or tool'}" autocomplete="off" spellcheck="false" value="${esc(wfLandingQuery)}"></div>` : '')
18845
+ + `</div>`;
18846
+ }
18847
+
18848
+ /** Switch the landing's tab: remember it, repaint, and (for a keyboard or button move) put focus on the chosen tab. */
18849
+ function setWorkflowsLandingTab(tab, focusTab) {
18850
+ const next = tab === 'pages' ? 'pages' : 'workflows';
18851
+ if (next !== wfLandingTab) {
18852
+ wfLandingTab = next;
18853
+ try { localStorage.setItem(WF_TAB_KEY, next); } catch { /* not remembered; the tab still switches */ }
18854
+ }
18855
+ renderWorkflowsLanding();
18856
+ if (focusTab) $wfLanding.querySelector(`[data-wf-tab="${next}"]`)?.focus();
18857
+ }
18858
+
18859
+ /** The Pages tab: the heading and tabs, the search, and a panel pages.js fills with every workflow's Page. */
18860
+ function renderWorkflowsPagesTab() {
18861
+ const focusedTab = document.activeElement?.closest?.('#wf-landing [data-wf-tab]')?.dataset.wfTab || null;
18862
+ const search = document.activeElement?.id === 'wf-landing-search' ? document.activeElement : null;
18863
+ const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
18864
+ const esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
18865
+ $wfLanding.innerHTML = workflowsLandingHeadHtml(esc, true)
18866
+ + '<div id="wf-pages-panel" class="wf-pages-panel" role="tabpanel" aria-labelledby="wf-tab-pages"></div>';
18867
+ const panel = $wfLanding.querySelector('#wf-pages-panel');
18868
+ if (window.flolessPages?.renderWorkflowsList) {
18869
+ void window.flolessPages.renderWorkflowsList(panel, {
18870
+ getQuery: () => wfLandingQuery,
18871
+ onAction: (act) => {
18872
+ if (act === 'show-workflows') setWorkflowsLandingTab('workflows', true);
18873
+ else if (act === 'clear-search') { setWorkflowsLandingQuery(''); $wfLanding.querySelector('#wf-landing-search')?.focus(); }
18874
+ },
18875
+ });
18876
+ } else {
18877
+ panel.innerHTML = '<div class="pg-empty" role="alert"><p>FloLess couldn’t load the workflows’ Pages. Check that FloLess is running, then try again.</p></div>';
18878
+ }
18879
+ if (focusedTab) $wfLanding.querySelector(`[data-wf-tab="${focusedTab}"]`)?.focus();
18880
+ if (keepCaret) { const box = $wfLanding.querySelector('#wf-landing-search'); box?.focus(); box?.setSelectionRange?.(keepCaret[0], keepCaret[1]); }
18881
+ }
18882
+
18693
18883
  function renderWorkflowsLanding() {
18694
18884
  if (!$wfLanding) return;
18885
+ if (wfLandingTab === 'pages') { renderWorkflowsPagesTab(); return; }
18886
+ const focusedTab = document.activeElement?.closest?.('#wf-landing [data-wf-tab]')?.dataset.wfTab || null;
18695
18887
  const focusedId = document.activeElement?.closest?.('#wf-landing [data-wf-id]')?.dataset.wfId || null;
18696
18888
  const search = document.activeElement?.id === 'wf-landing-search' ? document.activeElement : null;
18697
18889
  const keepCaret = search ? [search.selectionStart, search.selectionEnd] : null;
18698
18890
  const clearFocused = document.activeElement?.id === 'wf-search-clear';
18699
18891
  const focusedDraft = document.activeElement?.closest?.('#wf-landing [data-wf-draft]')?.dataset.wfDraft || null;
18700
18892
  const focusedRestore = document.activeElement?.closest?.('[data-wf-restore]')?.dataset.wfRestore || null;
18701
- // The Archived disclosure keeps its open state across repaints (apps-changed, search, restore); focus inside it implies open.
18702
- // Focus on the summary alone must NOT force it open (the person just closed it); focus on a card inside must.
18703
- const keepArchivedOpen = !!$wfLanding.querySelector('.wf-archived')?.open || !!document.activeElement?.closest?.('.wf-archived > .ws-grid');
18704
- const keepSearchOpened = !!$wfLanding.querySelector('.wf-archived')?.dataset.searchOpened;
18705
- const archivedSummaryFocused = !!document.activeElement?.closest?.('.wf-archived > summary');
18893
+ // Every section (Your workflows, Installed, Archived) is the same disclosure, and each keeps its open state across
18894
+ // repaints (apps-changed, search, restore, coming back to the tab); focus on a card inside implies open. Focus on
18895
+ // the summary alone must NOT force it open (the person just closed it).
18896
+ const keptSections = {};
18897
+ for (const box of $wfLanding.querySelectorAll('.wf-section')) {
18898
+ keptSections[box.dataset.wfSection] = {
18899
+ open: !!box.open || document.activeElement?.closest?.('.wf-section > .ws-grid')?.parentElement === box,
18900
+ searchOpened: !!box.dataset.searchOpened,
18901
+ summaryFocused: document.activeElement?.closest?.('.wf-section > summary')?.parentElement === box,
18902
+ };
18903
+ }
18706
18904
  const focusedRestored = document.activeElement?.closest?.('[data-wf-restored]')?.dataset.wfRestored || null;
18707
18905
  const esc = (s) => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
18708
18906
  const restoredRows = wfOwned.filter((row) => row.status !== 'archived' && row.restoreRefreshState);
@@ -18750,28 +18948,34 @@
18750
18948
  + `<div class="ws-name">${esc(name)}</div><div class="ws-meta">${esc(where)}</div>`
18751
18949
  + `<div class="ws-meta wf-card-nodes">${esc(workflowCardMeta(row))}</div></div></div></div>`;
18752
18950
  };
18753
- const group = (title, rows, show) => (rows.length
18754
- ? `${show ? `<div class="wf-group-label">${esc(title)} (${rows.length})</div>` : ''}<div class="ws-grid">${rows.map(card).join('')}</div>` : '');
18755
- const yours = unlisted.length + owned.length + restoredRows.length;
18756
- const both = yours > 0 && installed.length > 0;
18757
- const yoursGroup = yours
18758
- ? `${both ? `<div class="wf-group-label">Your workflows (${yours})</div>` : ''}<div class="ws-grid">${unlisted.map(draftCard).join('')}${owned.map(card).join('')}${restoredRows.map(restoredCard).join('')}</div>`
18759
- : '';
18760
- $wfLanding.innerHTML = `<div class="ws-head"><div class="ws-head-text"><h2 tabindex="-1" id="wf-landing-title">Workflows</h2>`
18761
- + `<p class="ws-sub">Build, run and manage the workflows behind your projects. Ask AI Chat on the left to build one with you.</p></div>`
18762
- + (wfLibrary.length || unlisted.length || archived.length || restoredRows.length ? `<div class="ws-head-actions"><input type="search" id="wf-landing-search" class="ws-landing-search" data-command-id="shell.workflows-landing-search" placeholder="Search workflows" aria-label="Search workflows by name, project or tool" autocomplete="off" spellcheck="false" value="${esc(wfLandingQuery)}"></div>` : '')
18763
- + `</div>`
18951
+ // One section: a disclosure whose summary names it and counts its cards. Your workflows and Installed start open,
18952
+ // Archived starts closed; a section the person opened or closed stays that way (keptSections). The summary's
18953
+ // Instructor carrier is passed whole by each caller: a command id is never assembled from parts.
18954
+ const section = (key, carrier, title, count, cards, openByDefault) => {
18955
+ if (!count) return '';
18956
+ const open = keptSections[key] ? keptSections[key].open : openByDefault;
18957
+ return `<details class="ws-archived wf-section wf-${key}" data-wf-section="${key}"${open ? ' open' : ''}>`
18958
+ + `<summary class="ws-archived-summary" ${carrier}><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>${title} <span class="ws-archived-count">${count}</span></summary>`
18959
+ + `<div class="ws-grid">${cards}</div></details>`;
18960
+ };
18961
+ const yoursSection = section('yours', 'data-command-id="shell.workflows-landing-yours"', 'Your workflows', unlisted.length + owned.length + restoredRows.length,
18962
+ `${unlisted.map(draftCard).join('')}${owned.map(card).join('')}${restoredRows.map(restoredCard).join('')}`, true);
18963
+ $wfLanding.innerHTML = workflowsLandingHeadHtml(esc, Boolean(wfLibrary.length || unlisted.length || archived.length || restoredRows.length))
18764
18964
  + `<div class="ws-create-grid"><div class="ws-card ws-create ws-card-create wf-create" role="button" tabindex="0" data-wf-new="1" data-command-id="shell.workflows-landing-new">`
18765
18965
  + `<div class="ws-thumb">+</div><div class="ws-body"><div><div class="ws-name">New workflow</div>`
18766
18966
  + `<div class="ws-meta">Name it and choose where it belongs. AI builds it with you.</div></div></div></div></div>`
18767
18967
  + unreadableNote
18768
18968
  + (wfLibrary.length || unlisted.length || archived.length || restoredRows.length
18769
- ? yoursGroup + group('Installed', installed, both)
18969
+ ? yoursSection + section('installed', 'data-command-id="shell.workflows-landing-installed"', 'Installed', installed.length, installed.map(card).join(''), true)
18970
+ + section('archived', 'data-command-id="shell.workflows-landing-archived"', 'Archived', archived.length, archived.map(archivedCard).join(''), false)
18770
18971
  + '<div class="ws-empty-note ws-search-empty" id="wf-search-empty" role="status" aria-live="polite"></div>'
18771
- : '<div class="ws-empty-note">No active workflows yet. Start with New workflow, or ask AI Chat on the left.</div>')
18772
- + (archived.length ? `<details class="ws-archived wf-archived"><summary class="ws-archived-summary" data-command-id="shell.workflows-landing-archived"><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>Archived <span class="ws-archived-count">${archived.length}</span></summary><div class="ws-grid">${archived.map(archivedCard).join('')}</div></details>` : '');
18773
- if (keepArchivedOpen) { const d = $wfLanding.querySelector('.wf-archived'); if (d) { d.open = true; if (keepSearchOpened) d.dataset.searchOpened = '1'; } }
18774
- if (archivedSummaryFocused) $wfLanding.querySelector('.wf-archived > summary')?.focus();
18972
+ : '<div class="ws-empty-note">No active workflows yet. Start with New workflow, or ask AI Chat on the left.</div>');
18973
+ for (const box of $wfLanding.querySelectorAll('.wf-section')) {
18974
+ const kept = keptSections[box.dataset.wfSection];
18975
+ if (kept?.open && kept.searchOpened) box.dataset.searchOpened = '1';
18976
+ if (kept?.summaryFocused) box.querySelector(':scope > summary')?.focus();
18977
+ }
18978
+ if (focusedTab) $wfLanding.querySelector(`[data-wf-tab="${focusedTab}"]`)?.focus();
18775
18979
  if (focusedId) $wfLanding.querySelector(`[data-wf-id="${CSS.escape(focusedId)}"]`)?.focus();
18776
18980
  if (focusedDraft) $wfLanding.querySelector(`[data-wf-draft="${CSS.escape(focusedDraft)}"]`)?.focus();
18777
18981
  if (focusedRestore) $wfLanding.querySelector(`[data-wf-restore="${CSS.escape(focusedRestore)}"]:not(:disabled)`)?.focus();
@@ -18784,10 +18988,12 @@
18784
18988
  /** Hide the workflow cards that don't match the landing search: every typed word must appear somewhere in the
18785
18989
  * card's name or the line under it (its project, or the tool an installed workflow runs on), never in its
18786
18990
  * "N nodes · tool" line, which every card has. New workflow is an action,
18787
- * not a result, so it stays. A group with nothing left hides its label; a shown label counts "1 of 3". */
18991
+ * not a result, so it stays. A section with nothing left hides whole; a shown one counts "1 of 3" in its summary. */
18788
18992
  function applyWorkflowsLandingSearch(caret) {
18789
18993
  const input = $wfLanding.querySelector('#wf-landing-search');
18790
18994
  if (!input) return;
18995
+ // The Pages tab filters its own rows (pages.js), from the same query.
18996
+ if (wfLandingTab === 'pages') { window.flolessPages?.repaintWorkflowsList?.($wfLanding.querySelector('#wf-pages-panel')); return; }
18791
18997
  const terms = wfLandingQuery.trim().toLowerCase().split(/\s+/).filter(Boolean);
18792
18998
  let shownAll = 0;
18793
18999
  for (const grid of $wfLanding.querySelectorAll('.ws-grid')) {
@@ -18798,23 +19004,15 @@
18798
19004
  card.hidden = !terms.every((t) => hay.includes(t));
18799
19005
  if (!card.hidden) shown++;
18800
19006
  }
18801
- const archivedBox = grid.closest('.wf-archived');
18802
- if (archivedBox) {
18803
- // The Archived disclosure counts in its summary; a search that matches opens it, an empty match hides all of it,
18804
- // and clearing the search closes it again only if the search was what opened it.
18805
- archivedBox.hidden = !shown;
18806
- const count = archivedBox.querySelector('.ws-archived-count');
19007
+ // Each section counts in its summary; a search that matches opens a closed one, an empty match hides all of it,
19008
+ // and clearing the search closes it again only if the search was what opened it.
19009
+ const box = grid.closest('.wf-section');
19010
+ if (box) {
19011
+ box.hidden = !shown;
19012
+ const count = box.querySelector('.ws-archived-count');
18807
19013
  if (count) count.textContent = terms.length ? `${shown} of ${cards.length}` : String(cards.length);
18808
- if (terms.length && shown && !archivedBox.open) { archivedBox.open = true; archivedBox.dataset.searchOpened = '1'; }
18809
- else if (!terms.length && archivedBox.dataset.searchOpened) { archivedBox.open = false; delete archivedBox.dataset.searchOpened; }
18810
- shownAll += shown;
18811
- continue;
18812
- }
18813
- grid.hidden = !shown;
18814
- const label = grid.previousElementSibling?.classList.contains('wf-group-label') ? grid.previousElementSibling : null;
18815
- if (label) {
18816
- label.hidden = !shown;
18817
- label.textContent = label.textContent.replace(/\(\d+(?: of \d+)?\)$/, terms.length ? `(${shown} of ${cards.length})` : `(${cards.length})`);
19014
+ if (terms.length && shown && !box.open) { box.open = true; box.dataset.searchOpened = '1'; }
19015
+ else if (!terms.length && box.dataset.searchOpened) { box.open = false; delete box.dataset.searchOpened; }
18818
19016
  }
18819
19017
  shownAll += shown;
18820
19018
  }
@@ -19089,8 +19287,8 @@
19089
19287
 
19090
19288
  if ($wfLanding) {
19091
19289
  $wfLanding.addEventListener('click', (event) => {
19092
- // A hand toggle of Archived means the person owns its state now: clearing the search must not undo it.
19093
- if (event.target.closest('.wf-archived > summary')) delete event.target.closest('.wf-archived').dataset.searchOpened;
19290
+ // A hand toggle of a section means the person owns its state now: clearing the search must not undo it.
19291
+ if (event.target.closest('.wf-section > summary')) delete event.target.closest('.wf-section').dataset.searchOpened;
19094
19292
  const restore = event.target.closest('[data-wf-restore]');
19095
19293
  if (restore) {
19096
19294
  if (!restore.disabled) {
@@ -19101,6 +19299,8 @@
19101
19299
  }
19102
19300
  return;
19103
19301
  }
19302
+ const tabEl = event.target.closest('[data-wf-tab]');
19303
+ if (tabEl) { setWorkflowsLandingTab(tabEl.dataset.wfTab, true); return; }
19104
19304
  if (event.target.closest('[data-wf-new]')) { requestNewWorkflow(); return; }
19105
19305
  // Clearing empties the message the button sits in, so focus goes back to the search box.
19106
19306
  if (event.target.closest('#wf-search-clear')) { setWorkflowsLandingQuery(''); $wfLanding.querySelector('#wf-landing-search')?.focus(); return; }
@@ -19119,6 +19319,17 @@
19119
19319
  if (event.key === 'Escape' && event.target.id === 'wf-landing-search' && event.target.value) {
19120
19320
  event.preventDefault(); event.stopPropagation(); setWorkflowsLandingQuery(''); return;
19121
19321
  }
19322
+ // The tabs move by arrow keys (the focused tab is the one tab stop) and activate as they take focus.
19323
+ const onTab = event.target.closest?.('[data-wf-tab]');
19324
+ if (onTab && ['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {
19325
+ event.preventDefault();
19326
+ const order = ['workflows', 'pages'];
19327
+ const at = order.indexOf(onTab.dataset.wfTab);
19328
+ const to = event.key === 'Home' ? 0 : event.key === 'End' ? order.length - 1
19329
+ : (at + (event.key === 'ArrowRight' ? 1 : order.length - 1)) % order.length;
19330
+ setWorkflowsLandingTab(order[to], true);
19331
+ return;
19332
+ }
19122
19333
  if (event.key !== 'Enter' && event.key !== ' ') return;
19123
19334
  const target = event.target.closest('[data-wf-id], [data-wf-new], [data-wf-draft]');
19124
19335
  if (!target || target !== event.target) return;