@floless/app 0.150.0 → 0.151.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;