@floless/app 0.150.0 → 0.152.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/web/app.js CHANGED
@@ -104,14 +104,9 @@ function renderCanvasPlaceholder(kind) {
104
104
  `</div>`;
105
105
  }
106
106
 
107
- // First-run onboarding card (the 'empty' placeholder). The primary action is "Start the guided tour"
108
- // — it copies a prompt the user pastes into their terminal AI to launch onboarding. No raw CLI command
109
- // is shown: the AI builds the workflows (per the headline), so the card stays AI-native, not "go run
110
- // this command yourself". No repeated brand mark (not a splash).
111
- // The natural-language launch prompt the "Start the guided tour" button copies. Phrased to match the
112
- // floless-app-onboarding skill's auto-trigger ("onboard me", "guided tour") so pasting it into Claude
113
- // Code / Codex starts the tour. Plain language (not a slash command) = portable across terminal hosts.
114
- const ONB_TOUR_PROMPT = 'Onboard me into floless.app and AWARE — give me the guided tour.';
107
+ // First-run onboarding card (the 'empty' placeholder). The primary action is "Ask the Guide" (#2046): FloLess's
108
+ // onboarding agent in AI Chat, which looks at this computer (with the person's agreement) and shows them around. It
109
+ // replaced the old "Start the guided tour" that copied a prompt for an external terminal; that prompt still works there.
115
110
  function onboardingHtml() {
116
111
  const step = (n, label, note) =>
117
112
  `<li><span class="onb-num">${n}</span><span class="onb-step"><span class="onb-step-label">${label}</span> <span class="onb-step-note">${note}</span></span></li>`;
@@ -120,9 +115,8 @@ function onboardingHtml() {
120
115
  `<div class="onb-headline">Your terminal AI builds the workflows.<br>You run and inspect them here.</div>` +
121
116
  `<div class="onb-sub">floless.app shows the canvas, triggers runs, and streams results. Compose in Claude Code or Codex; the browser is the window.</div>` +
122
117
  `<div class="onb-tour">` +
123
- `<span class="onb-tour-hint">New here? Copies a prompt — paste it into Claude Code or Codex.</span>` +
124
- `<button class="onb-tour-btn" type="button" aria-label="Start the guided tour — copies the onboarding prompt to your clipboard"><span class="onb-tour-label">Start the guided tour</span><span class="onb-tour-ico" aria-hidden="true">⎘</span></button>` +
125
- `<span class="sr-only onb-tour-live" aria-live="polite"></span>` +
118
+ `<span class="onb-tour-hint">New here? The Guide looks at your setup in AI Chat and suggests where to start.</span>` +
119
+ `<button class="onb-tour-btn" type="button" data-command-id="shell.ask-guide#the Workflows page" data-tip="Ask the Guide in AI Chat to look at your setup and suggest what to do first."><span class="onb-tour-label">Ask the Guide</span><span class="onb-tour-ico" aria-hidden="true">→</span></button>` +
126
120
  `</div>` +
127
121
  `<div class="onb-divider"></div>` +
128
122
  `<ol class="onb-steps">` +
@@ -135,107 +129,18 @@ function onboardingHtml() {
135
129
  `</div>`
136
130
  );
137
131
  }
138
- // Wire a "Start the guided tour" button: copy the natural-language onboarding prompt so the user can
139
- // paste it into their terminal AI to launch the tour (the floless-app-onboarding skill), and confirm
140
- // in place. SHARED — the Workflows first-run card below and the Workspaces zero-projects empty state
141
- // (workspaces.js, #598) are two entry points to the SAME tour, so they must not drift in prompt text,
142
- // confirmation wording, or reset timing; one function is what guarantees that.
143
- // Markup contract: a button may be bare text (it is then its own label), or split into
144
- // `.onb-tour-label` + `.onb-tour-ico` — never an icon span with no label span, which would have the
145
- // label swap wipe the icon out. Its `[aria-live]` region is found as a sibling rather than passed in,
146
- // so a call site cannot quietly wire a button with no way to announce the result.
147
- function wireTourCopy(btn) {
132
+ // Wire an "Ask the Guide" button (#2046). SHARED — the Workflows first-run card and the Workspaces zero-projects empty
133
+ // state (workspaces.js) are two ways into the same Guide, so they must behave the same; one function guarantees that.
134
+ function wireAskGuide(btn) {
148
135
  if (!btn) return;
149
- const ico = btn.querySelector('.onb-tour-ico');
150
- const label = btn.querySelector('.onb-tour-label') || btn;
151
- // Loud, because that mistake is otherwise invisible AND permanent: with no label span the swap below
152
- // writes over the whole button, destroying the icon element, and the reset restores flat text. The
153
- // button keeps "working", so nothing else would ever report it.
154
- if (ico && label === btn) console.error('[onboarding] a tour button with .onb-tour-ico must also have .onb-tour-label — the label swap will destroy the icon', btn);
155
- const live = btn.parentElement ? btn.parentElement.querySelector('[aria-live]') : null;
156
- // Equally loud. Finding the region by structure keeps the two call sites from passing mismatched
157
- // selectors, but it also means an extra wrapper around the button silently costs every screen-reader
158
- // announcement — and the four `if (live)` guards below would hide that forever. Say so instead.
159
- if (!live) console.error('[onboarding] no [aria-live] sibling for this tour button — the copy result will not be announced', btn);
160
- // Read the idle text off the DOM rather than hardcoding it — the two call sites label the action
161
- // differently ("Start the guided tour" vs "Start the guided tour →") and only the markup knows which.
162
- const idleLabel = label.textContent;
163
- const idleIco = ico ? ico.textContent : '';
164
- btn.onclick = async () => {
165
- // ONLY the copy goes inside the try. Wrapping the confirmation too meant a throw anywhere in it
166
- // (showToast dereferences #toast-container unguarded) landed in the catch with the button already
167
- // disabled and the reset never scheduled — a permanently stuck "Copied ✓" under a toast saying the
168
- // copy failed. That was the one path where this button could actively misinform.
169
- try {
170
- await navigator.clipboard.writeText(ONB_TOUR_PROMPT);
171
- } catch (err) {
172
- // Bind and log it: "navigator.clipboard is undefined" (insecure context / blocked by policy —
173
- // permanent) and "writeText rejected" (denied, or the document wasn't focused — often retryable)
174
- // reach the user as one message, and with nothing logged a bug report can't separate them either.
175
- console.error('[onboarding] could not copy the tour prompt', err);
176
- revealTourPrompt(btn, live);
177
- return;
178
- }
179
- // Disabling a focused control blurs it, and re-enabling does NOT bring focus back — so a keyboard
180
- // user would be dropped to <body> for the whole confirmation and have to tab in from the top
181
- // again. Restore it: the same discipline retryProjects() applies on this very surface.
182
- // MUST be read before disabling, which blurs it — after, this is always false.
183
- const hadFocus = document.activeElement === btn;
184
- btn.disabled = true;
185
- label.textContent = 'Copied';
186
- if (ico) ico.textContent = '✓';
187
- if (live) live.textContent = 'Copied to clipboard';
188
- // A successful copy retires any prompt a previous refusal put on screen — otherwise a stale
189
- // "copy this manually" field sits under a button reading "Copied ✓", contradicting it.
190
- const stale = btn.parentElement ? btn.parentElement.querySelector('.onb-tour-manual') : null;
191
- if (stale) stale.remove();
192
- setTimeout(() => {
193
- label.textContent = idleLabel;
194
- if (ico) ico.textContent = idleIco;
195
- btn.disabled = false;
196
- if (live) live.textContent = '';
197
- // Only take focus back if it is still nowhere. 1600 ms is long enough for the user to click or
198
- // tab onto something else — and a mouse click focuses the button too, so `hadFocus` alone would
199
- // yank focus out of whatever they moved to. isConnected because a repaint may have replaced this
200
- // node, and focusing a detached button drops them to <body>: the very thing this prevents.
201
- const parked = document.activeElement;
202
- if (hadFocus && btn.isConnected && (!parked || parked === document.body)) {
203
- btn.focus({ focusVisible: true, preventScroll: true });
204
- }
205
- }, 1600);
206
- showToast('Copied — paste it into your terminal AI', 'ok');
136
+ btn.onclick = () => {
137
+ if (window.flolessGuide?.open) { void window.flolessGuide.open({ returnFocus: btn }); return; }
138
+ showToast('The Guide isn’t ready yet. Try again in a moment, or open it from ≡ → Guide.', 'warn');
207
139
  };
208
140
  }
209
- // The clipboard is this button's ONLY route into onboarding, and the prompt is rendered nowhere — so
210
- // "copy it manually" asks for something the user cannot do: there is nothing on screen to copy. Put
211
- // the prompt on screen, selected, and the message becomes true. Both entry points inherit this.
212
- function revealTourPrompt(btn, live) {
213
- const host = btn.parentElement;
214
- let box = host ? host.querySelector('.onb-tour-manual') : null;
215
- if (host && !box) {
216
- // A textarea, not an input: the prompt is wider than the Workflows card, and a single-line input
217
- // clips it mid-sentence. Selecting still copies the whole thing, but "copy it manually" is only
218
- // honest if the user can also READ what they are copying.
219
- box = document.createElement('textarea');
220
- box.className = 'onb-tour-manual';
221
- box.rows = 2;
222
- box.readOnly = true;
223
- box.value = ONB_TOUR_PROMPT;
224
- box.setAttribute('aria-label', 'The onboarding prompt — copy this and paste it into your terminal AI');
225
- host.appendChild(box);
226
- }
227
- // focus+setSelectionRange, not select(): select() scrolls the element into view with no way to
228
- // opt out, and on the Workflows card that means scrolling inside .canvas (overflow:hidden) whose
229
- // .topology child is the pan/zoom transformed world — a scrollTop nothing can put back.
230
- if (box) { box.focus({ preventScroll: true }); box.setSelectionRange(0, box.value.length); }
231
- if (live) live.textContent = 'Could not copy. The prompt is now shown — copy it manually.';
232
- showToast(box
233
- ? 'Couldn’t reach the clipboard — the prompt is shown below; copy it manually.'
234
- : 'Could not copy — this browser is blocking the clipboard.', 'warn');
235
- }
236
141
  function wireOnboardingCopy() {
237
142
  // The primary first-run action on the empty canvas.
238
- wireTourCopy($topology.querySelector('.onb-tour-btn'));
143
+ wireAskGuide($topology.querySelector('.onb-tour-btn'));
239
144
  // Secondary first-run action: "Build your first workflow" — the empty canvas is the
240
145
  // highest-intent moment to create one, so surface the same relay the ≡ menu's "New
241
146
  // workflow…" fires (handleMenuAction is reassigned in aware.js → requestNewWorkflow).
@@ -1388,6 +1293,8 @@ function handleMenuAction(action) {
1388
1293
  case 'routines': openRoutines(); break;
1389
1294
  case 'tool-update-policy': if (typeof window.openToolUpdatePolicy === 'function') window.openToolUpdatePolicy(); break;
1390
1295
  case 'report-issue': openReportIssue(); break;
1296
+ // #2046: the Guide — opens its conversation, or asks first (web/guide.js).
1297
+ case 'guide': if (window.flolessGuide) void window.flolessGuide.open({ returnFocus: document.getElementById('menu-btn') }); break;
1391
1298
  case 'fullscreen': toggleFullscreen(); break;
1392
1299
  // Asks first (unsaved work, a running workflow) — see web/leave-guard.js.
1393
1300
  case 'stop-app': if (window.flolessLeaveGuard) window.flolessLeaveGuard.stopApp(); break;
@@ -1515,14 +1422,45 @@ const $startupToggle = document.getElementById('startup-toggle');
1515
1422
  async function refreshStartup() {
1516
1423
  try {
1517
1424
  const r = await fetch('/api/autostart');
1518
- if (!r.ok) { if ($startupRow) $startupRow.hidden = true; return; }
1425
+ if (!r.ok) { if ($startupRow) $startupRow.hidden = true; showStartOnLoginLinks(false); return; }
1519
1426
  const d = await r.json();
1520
1427
  const supported = !!d.supported;
1521
1428
  if ($startupRow) $startupRow.hidden = !supported;
1522
1429
  if (supported && $startupToggle) $startupToggle.checked = !!d.enabled;
1523
- } catch { if ($startupRow) $startupRow.hidden = true; }
1430
+ showStartOnLoginLinks(supported);
1431
+ } catch { if ($startupRow) $startupRow.hidden = true; showStartOnLoginLinks(false); }
1432
+ }
1433
+
1434
+ // #2062: Routines run only while FloLess is running, so their dialogs point to this setting. The links follow the
1435
+ // row: shown only where the setting exists (hide, never a dead control).
1436
+ function showStartOnLoginLinks(supported) {
1437
+ document.querySelectorAll('[data-start-on-login-link], [data-start-on-login-hint]').forEach((node) => { node.hidden = !supported; });
1524
1438
  }
1525
1439
 
1440
+ /** #2062: close whatever dialog asked, open the ≡ menu and put focus on the start-on-login switch. */
1441
+ async function revealStartOnLogin() {
1442
+ // Read the setting first: if it has gone (or can't be read), say so and leave Routines open.
1443
+ await refreshStartup();
1444
+ if (!$startupRow || $startupRow.hidden || !$startupToggle) {
1445
+ showToast('Start on startup isn’t available on this computer right now, so FloLess runs routines only while you keep it open.', 'warn');
1446
+ return;
1447
+ }
1448
+ // Only the Routines list carries the link (the editor would drop a routine being written).
1449
+ document.getElementById('routines-modal')?.classList.remove('show');
1450
+ toggleMenu(true);
1451
+ $startupRow.classList.remove('is-pointed');
1452
+ void $startupRow.offsetWidth; // re-arm the highlight on a repeat
1453
+ $startupRow.classList.add('is-pointed');
1454
+ $startupToggle.focus({ preventScroll: false });
1455
+ }
1456
+ document.addEventListener('click', (event) => {
1457
+ const link = event.target.closest?.('[data-start-on-login-link]');
1458
+ if (!link) return;
1459
+ event.preventDefault();
1460
+ event.stopPropagation(); // the document handler above would close the menu this opens
1461
+ void revealStartOnLogin();
1462
+ }, true);
1463
+
1526
1464
  if ($startupToggle) {
1527
1465
  $startupToggle.addEventListener('change', async () => {
1528
1466
  const want = $startupToggle.checked;
@@ -1796,10 +1734,20 @@ document.getElementById('zoom-reset').onclick = () => { resetView(); autoFit = f
1796
1734
  const $zoomFit = document.getElementById('zoom-fit');
1797
1735
  if ($zoomFit) $zoomFit.onclick = () => { fitToScreen(); autoFit = true; };
1798
1736
 
1737
+ // The canvas also hosts project, library and Agents pages. Only the visible workflow
1738
+ // graph owns pan/zoom gestures; other surfaces keep native focus, selection and scrolling.
1739
+ const $canvasEl = document.querySelector('.canvas');
1740
+ function workflowCanvasGesture(target) {
1741
+ if ($app.classList.contains('mode-workspaces') || $app.classList.contains('mode-agents')
1742
+ || document.body.classList.contains('wf-landing-open') || document.body.classList.contains('wf-draft-open')
1743
+ || $canvasEl.classList.contains('view-dashboard') || !$topology.getClientRects().length) return false;
1744
+ return !target?.closest?.('#ws-landing, #ws-project, #wf-landing, #wf-draft, #agents-surface, .dashboard');
1745
+ }
1746
+
1799
1747
  // Ctrl/Cmd + scroll wheel = zoom on canvas (skips OS-level browser zoom)
1800
1748
  let zoomAccum = 0;
1801
1749
  document.querySelector('.canvas').addEventListener('wheel', (e) => {
1802
- if (!e.ctrlKey && !e.metaKey) return;
1750
+ if ((!e.ctrlKey && !e.metaKey) || !workflowCanvasGesture(e.target)) return;
1803
1751
  e.preventDefault();
1804
1752
  zoomAccum += e.deltaY;
1805
1753
  if (Math.abs(zoomAccum) >= 40) {
@@ -1811,7 +1759,6 @@ document.querySelector('.canvas').addEventListener('wheel', (e) => {
1811
1759
  // Middle-mouse drag = pan the (possibly zoomed) canvas. preventDefault on the middle
1812
1760
  // button suppresses Windows' autoscroll bubble; the offset is screen-px (1:1 with the
1813
1761
  // cursor) because translate sits OUTSIDE the scale in the transform list.
1814
- const $canvasEl = document.querySelector('.canvas');
1815
1762
  let panning = false, panFromX = 0, panFromY = 0, panBaseX = 0, panBaseY = 0;
1816
1763
  function startPan(e) {
1817
1764
  panning = true;
@@ -1821,7 +1768,7 @@ function startPan(e) {
1821
1768
  }
1822
1769
  // Middle-mouse drag anywhere on the canvas pans (the classic gesture).
1823
1770
  $canvasEl.addEventListener('mousedown', (e) => {
1824
- if (e.button !== 1) return;
1771
+ if (e.button !== 1 || !workflowCanvasGesture(e.target)) return;
1825
1772
  e.preventDefault();
1826
1773
  startPan(e);
1827
1774
  });
@@ -1834,7 +1781,7 @@ $canvasEl.addEventListener('mousedown', (e) => {
1834
1781
  // `.dashboard` (the custom-panels view that replaces the topology) is excluded too — it has
1835
1782
  // its own scroll/click surface and the topology it would pan is hidden in that view.
1836
1783
  $canvasEl.addEventListener('mousedown', (e) => {
1837
- if (e.button !== 0 || e.target.closest('.agent-card, .canvas-toolbar, .fav-bar, .find-overlay, .dashboard')) return;
1784
+ if (e.button !== 0 || !workflowCanvasGesture(e.target) || e.target.closest('.agent-card, .canvas-toolbar, .fav-bar, .find-overlay, .dashboard, input, textarea, select, button, [contenteditable]')) return;
1838
1785
  e.preventDefault();
1839
1786
  startPan(e);
1840
1787
  });
@@ -1850,7 +1797,7 @@ window.addEventListener('mouseup', () => {
1850
1797
  panning = false;
1851
1798
  $canvasEl.classList.remove('panning');
1852
1799
  });
1853
- $canvasEl.addEventListener('auxclick', (e) => { if (e.button === 1) e.preventDefault(); });
1800
+ $canvasEl.addEventListener('auxclick', (e) => { if (e.button === 1 && workflowCanvasGesture(e.target)) e.preventDefault(); });
1854
1801
 
1855
1802
  // ----- Touch: one-finger pan + two-finger pinch-zoom (phones). The mouse handlers above are
1856
1803
  // untouched (touch events never fire from a mouse), so desktop is unaffected. touch-action:none
@@ -1858,13 +1805,14 @@ $canvasEl.addEventListener('auxclick', (e) => { if (e.button === 1) e.preventDef
1858
1805
  let tPan = false, tPinch = false, tFromX = 0, tFromY = 0, tBaseX = 0, tBaseY = 0, pinchDist0 = 0, pinchZoom0 = 1;
1859
1806
  const pinchSpan = (ts) => Math.hypot(ts[0].clientX - ts[1].clientX, ts[0].clientY - ts[1].clientY);
1860
1807
  $canvasEl.addEventListener('touchstart', (e) => {
1808
+ if (!workflowCanvasGesture(e.target)) return;
1861
1809
  if (e.touches.length === 2) {
1862
1810
  e.preventDefault();
1863
1811
  tPinch = true; tPan = false;
1864
1812
  pinchDist0 = pinchSpan(e.touches) || 1; pinchZoom0 = zoom;
1865
1813
  } else if (e.touches.length === 1) {
1866
1814
  // Let taps on interactive chrome through (node select, zoom toolbar, fav-bar, find, dashboard).
1867
- if (e.target.closest('.agent-card, .canvas-toolbar, .fav-bar, .find-overlay, .dashboard')) return;
1815
+ if (e.target.closest('.agent-card, .canvas-toolbar, .fav-bar, .find-overlay, .dashboard, input, textarea, select, button, [contenteditable]')) return;
1868
1816
  e.preventDefault();
1869
1817
  tPan = true; tPinch = false;
1870
1818
  tFromX = e.touches[0].clientX; tFromY = e.touches[0].clientY;
@@ -1969,6 +1917,10 @@ function setWorkspaceRootError(message) {
1969
1917
 
1970
1918
  function workspaceRootErrorMessage(error) {
1971
1919
  const raw = String(error && error.message || error || 'Could not use that folder.');
1920
+ const uncheckedProjects = "FloLess can't switch to this folder yet. It contains projects, and another saved directory can't be checked right now, so FloLess can't confirm those projects aren't already saved there. For now, cancel this review and choose an empty Workspace directory. You can switch to this folder once every other saved directory is available or stopped.";
1921
+ if (raw === 'You stopped using this directory. Restore its registration under Saved directories, then switch to it.'
1922
+ || /^This folder is inside or contains .+, a directory you stopped using\. FloLess still reserves it so projects stay unique\. Choose a folder outside this saved directory\.$/.test(raw)
1923
+ || raw === uncheckedProjects || raw === `Nothing was changed. ${uncheckedProjects}`) return raw;
1972
1924
  if (/folders? may not contain one another/i.test(raw)) {
1973
1925
  return 'Choose a different folder. A Workspace directory cannot be inside another FloLess Workspace directory.';
1974
1926
  }