@floless/app 0.162.1 → 0.164.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 (39) hide show
  1. package/dist/floless-server.cjs +39748 -35132
  2. package/dist/schemas/steel.model.v2.schema.json +16 -2
  3. package/dist/skills/floless-app-actions/SKILL.md +54 -3
  4. package/dist/skills/floless-app-onboarding/SKILL.md +2 -2
  5. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +8 -6
  6. package/dist/skills/floless-app-report-issue/SKILL.md +12 -1
  7. package/dist/skills/floless-app-rfi/SKILL.md +36 -9
  8. package/dist/skills/floless-app-steel-model/SKILL.md +5 -3
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +39 -34
  10. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +10 -6
  11. package/dist/web/agents.js +24 -4
  12. package/dist/web/app.css +47 -7
  13. package/dist/web/app.js +22 -3
  14. package/dist/web/aware.js +157 -43
  15. package/dist/web/chat.css +36 -1
  16. package/dist/web/chat.js +322 -44
  17. package/dist/web/commands-filter.js +35 -0
  18. package/dist/web/commands-shell.js +208 -11
  19. package/dist/web/commands-steel.js +23 -0
  20. package/dist/web/failure-copy.js +168 -0
  21. package/dist/web/index.html +35 -1
  22. package/dist/web/instructor.js +3 -1
  23. package/dist/web/landing-sort.js +277 -0
  24. package/dist/web/model-editor-steel-adapter.js +5 -0
  25. package/dist/web/model-panel-bridge.js +13 -2
  26. package/dist/web/model-view-query.js +23 -15
  27. package/dist/web/project-access.js +3 -3
  28. package/dist/web/project-rfis.js +303 -10
  29. package/dist/web/project-workflows.js +1 -1
  30. package/dist/web/steel-3d-view.js +162 -1
  31. package/dist/web/steel-ai-marks.js +233 -0
  32. package/dist/web/steel-editor.html +950 -36
  33. package/dist/web/steel-filter-core.js +2 -0
  34. package/dist/web/steel-filter-flo.js +225 -0
  35. package/dist/web/steel-filter.html +156 -9
  36. package/dist/web/steel-model-v2-commands.js +3 -1
  37. package/dist/web/steel-profile-colours.js +124 -24
  38. package/dist/web/workspaces.js +380 -58
  39. package/package.json +1 -1
@@ -45,6 +45,23 @@
45
45
  : r?.status === 'ready' ? '' : (r?.message || READINESS_TEXT[r?.status] || 'Gmail sending isn’t available just now.'));
46
46
  const unresolved = (d) => d && (d.status === 'prepared' || d.status === 'outcome-unknown');
47
47
  const HELD = 'Mark sent, Answer and Close are held back until this is settled, so the RFI’s history stays true.';
48
+ /** The ways out of a send FloLess couldn't confirm (#2470 R6.6e): only those the server offers, never preselected. */
49
+ const SETTLE_WAYS = [
50
+ { key: 'try-again', allowed: 'canTryAgain', label: 'Send it again with Gmail', help: 'They may get it twice.', primary: 'Send it again…' },
51
+ { key: 'sent-another-way', allowed: 'canRecordSentAnotherWay', label: 'I sent it another way', help: 'Record it. FloLess sends nothing.', primary: 'Record as sent' },
52
+ { key: 'leave-unconfirmed', allowed: 'canLeaveUnconfirmed', label: 'Leave it unconfirmed', help: 'Free the RFI without saying it was sent.', primary: 'Leave unconfirmed' },
53
+ ];
54
+ const LEAVE_TEXT = 'FloLess won’t finish or send this, and can’t say whether Gmail already did. The RFI is free again, and its history will show this send as not confirmed.';
55
+ const SETTLED_WORDS = { 'try-again': 'sent again with Gmail', 'sent-another-way': 'sent another way', 'left-unconfirmed': 'left unconfirmed' };
56
+ // What became of the new send of a Try again: said only as far as FloLess knows it (a refused one reached nobody).
57
+ const resendWords = (status) => !status || status === 'recorded' || status === 'confirmed-sent' ? ''
58
+ : status === 'failed' ? ' · Gmail didn’t receive the new send' : ' · the new send isn’t confirmed either';
59
+ // Refusals that mean the list on screen is out of date: the form closes and the list is read again.
60
+ const SETTLE_OUT_OF_DATE = new Set(['rfi-delivery-terminal', 'rfi-delivery-stale', 'rfi-revision-stale', 'rfi-delivery-evidence-present', 'rfi-delivery-not-found']);
61
+ const HOW_MAX = 120;
62
+ /** A send that holds this RFI, live or from before it changed, by its attempt id. */
63
+ const heldAttempt = (rfi, attemptId) => (rfi?.holdingDeliveries || []).find((h) => h.attemptId === attemptId)
64
+ || (rfi?.delivery?.attemptId === attemptId && unresolved(rfi.delivery) ? rfi.delivery : null);
48
65
 
49
66
  function ago(iso, now = Date.now()) {
50
67
  const t = Date.parse(iso);
@@ -171,6 +188,51 @@
171
188
  aria-label="${esc(`Send ${rfi.id} with Gmail`)}"${held}>${form.uncertain ? 'Try again' : form.busy ? 'Sending…' : 'Send email'}</button>
172
189
  </div></div>`;
173
190
  }
191
+ case 'settle': {
192
+ const held = heldAttempt(rfi, form.attemptId);
193
+ if (!held) return '';
194
+ const ways = SETTLE_WAYS.filter((w) => held[w.allowed]);
195
+ const way = draft.way || '';
196
+ const off = form.busy || form.uncertain ? ' disabled' : '';
197
+ const frozen = form.busy || form.uncertain ? ' readonly' : '';
198
+ const intro = held.stale
199
+ ? `<p class="pm-note">This earlier send to ${esc(held.to || '')} (${esc(ago(held.preparedAt))}) is from before this RFI last changed, so the only way to settle it is to leave it unconfirmed.</p>`
200
+ : '';
201
+ const radios = ways.length > 1 ? `<div class="pr-radios" role="radiogroup" aria-label="What do you want to do?">${ways.map((w, i) => {
202
+ const on = way === w.key;
203
+ return `<button type="button" class="pr-radio" role="radio" aria-checked="${on}" tabindex="${on || (!way && i === 0) ? 0 : -1}" data-pr-way="${w.key}"
204
+ data-command-id="shell.project-rfi-settle-way#${esc(w.key)}" data-command-instance-label="${esc(w.label)}"${off}><span class="pr-radio-dot" aria-hidden="true"></span>
205
+ <span><span class="pr-radio-label">${esc(w.label)}</span><span class="pg-row-meta">${esc(w.help)}</span></span></button>`;
206
+ }).join('')}</div>` : '';
207
+ let detail = '';
208
+ if (way === 'sent-another-way') {
209
+ const via = draft.via || '';
210
+ const how = String(draft.how || '');
211
+ detail = `<div class="pr-radios" role="radiogroup" aria-label="How did you send it?">${[['email', 'Email'], ['other', 'Other']].map(([key, text], i) => {
212
+ const on = via === key;
213
+ return `<button type="button" class="pr-radio" role="radio" aria-checked="${on}" tabindex="${on || (!via && i === 0) ? 0 : -1}" data-pr-via="${key}"
214
+ data-command-id="shell.project-rfi-settle-via#${esc(key)}" data-command-instance-label="${text}"${off}><span class="pr-radio-dot" aria-hidden="true"></span>
215
+ <span class="pr-radio-label">${text}</span></button>`;
216
+ }).join('')}</div>
217
+ <label class="pr-field">Who did you send it to?<input type="email" class="pr-input" data-pr-input="to" value="${esc(draft.to ?? held.to ?? '')}" autocomplete="email"
218
+ data-command-id="shell.project-rfi-settle-to#${esc(rfi.id)}" data-command-instance-label="${id}"${frozen}></label>
219
+ ${via === 'other' ? `<label class="pr-field">How did you send it?<input class="pr-input" data-pr-input="how" maxlength="${HOW_MAX}" value="${esc(how)}"
220
+ placeholder="Handed over at the site meeting" data-command-id="shell.project-rfi-settle-how#${esc(rfi.id)}" data-command-instance-label="${id}"${frozen}>
221
+ <span class="pg-row-meta" data-pr-how-count>${how.length} of ${HOW_MAX}</span></label>` : ''}
222
+ <p class="pg-row-meta">FloLess records this and marks the RFI sent. It sends nothing.</p>`;
223
+ } else if (way === 'leave-unconfirmed') detail = `<p class="pg-row-meta">${LEAVE_TEXT}</p>`;
224
+ else if (way === 'try-again') detail = '<p class="pg-row-meta">Gmail sends this RFI as a new email. FloLess asks you to confirm first.</p>';
225
+ const chosen = SETTLE_WAYS.find((w) => w.key === way);
226
+ const lost = form.uncertain ? '<p class="pm-note pr-alert" role="alert">FloLess didn’t get an answer, so it can’t tell whether that was recorded. Try again does the same thing again, never twice.</p>' : '';
227
+ const err = form.error ? `<p class="pm-note pr-alert" role="alert">${esc(form.error)}</p>` : '';
228
+ return `<div class="pr-form" role="group" aria-label="${esc(`Settle the unconfirmed send of ${rfi.id}`)}"${form.busy ? ' aria-busy="true"' : ''}>${intro}${radios}${detail}${err}${lost}
229
+ <div class="pm-strip-acts pr-form-acts">
230
+ ${form.uncertain
231
+ ? `<button type="button" class="ghost" data-pr-gmail-check="1" data-command-id="shell.project-rfi-gmail-check-list#${esc(rfi.id)}" data-command-instance-label="${id}">Check the list</button>`
232
+ : `<button type="button" class="ghost" data-pr-form-cancel="1" data-command-id="shell.project-rfi-form-cancel#${esc(rfi.id)}" data-command-instance-label="${id}"${busy}>Cancel</button>`}
233
+ <button type="button" class="primary" data-pr-form-submit="1" data-command-id="shell.project-rfi-settle-submit#${esc(rfi.id)}" data-command-instance-label="${id}"${busy}>${form.uncertain ? 'Try again' : form.busy ? 'Saving…' : esc(chosen?.primary || 'Choose one')}</button>
234
+ </div></div>`;
235
+ }
174
236
  case 'reopen':
175
237
  fields = `<label class="pr-field">Why is this open again?<textarea class="pr-input pr-text" data-pr-input="why" rows="2" maxlength="1000"
176
238
  data-command-id="shell.project-rfi-reopen-why#${esc(rfi.id)}" data-command-instance-label="${id}"${busy}${ro}>${esc(draft.why || '')}</textarea></label>`;
@@ -186,11 +248,18 @@
186
248
  </div></div>`;
187
249
  }
188
250
 
251
+ /** The ghost button that opens the ways out of a held send, when the server offers one (#2470 R6.6e). */
252
+ function settleButton(rfi, d, text) {
253
+ if (!SETTLE_WAYS.some((w) => d[w.allowed])) return '';
254
+ return `<button type="button" class="ghost" data-pr-settle="${esc(rfi.id)}" data-pr-attempt="${esc(d.attemptId)}" data-command-id="shell.project-rfis-gmail-settle#${esc(rfi.id)}"
255
+ data-command-instance-label="${esc(rfi.id)}" aria-label="${esc(`${text.replace('…', '')}: ${rfi.id}`)}" data-tip="Other ways to settle this send: send it again, record that you sent it, or leave it unconfirmed">${text}</button>`;
256
+ }
257
+
189
258
  function rowHtml(rfi, now) {
190
259
  const id = esc(rfi.id);
191
260
  const label = `data-command-instance-label="${id}"`;
192
261
  const meta = [];
193
- if (rfi.sent) meta.push(`<span data-tip="${esc(exact(rfi.sent.at))}">${rfi.sent.via === 'gmail' ? 'Sent with Gmail to' : 'Marked sent to'} ${esc(rfi.sent.to)} · ${esc(ago(rfi.sent.at, now))}</span>`);
262
+ if (rfi.sent) meta.push(`<span data-tip="${esc(exact(rfi.sent.at))}">${rfi.sent.via === 'gmail' ? 'Sent with Gmail to' : rfi.sent.via === 'other' ? `Sent another way (${esc(rfi.sent.how || '')}) to` : 'Marked sent to'} ${esc(rfi.sent.to)} · ${esc(ago(rfi.sent.at, now))}</span>`);
194
263
  else meta.push(`<span data-tip="${esc(exact(rfi.raisedAt))}">Filed ${esc(ago(rfi.raisedAt, now))}${rfi.raisedBy === 'ai' ? ' by AI Chat' : ''}</span>`);
195
264
  if (rfi.reopens) meta.push(`Reopened ${rfi.reopens === 1 ? 'once' : `${rfi.reopens} times`}`);
196
265
  const answer = rfi.answer ? `<blockquote class="pr-answer"><span class="pr-answer-label">Answer</span> ${esc(rfi.answer.text)}</blockquote>` : '';
@@ -211,20 +280,36 @@
211
280
  : d.status === 'confirmed-sent' ? `You confirmed it in Sent on ${esc(exact(d.settledAt || ''))}.`
212
281
  : d.status === 'failed' ? (rfi.status === 'open' ? 'Gmail didn’t receive this RFI, so nothing was sent. Send it again, or copy the email text and send it yourself.' : '')
213
282
  : d.status === 'prepared' ? `FloLess began sending this with Gmail but didn’t finish recording it, so it can’t tell whether it went. Don’t send it again. Choose Finish sending. ${HELD}`
214
- : `FloLess can’t tell whether Gmail accepted this RFI. Don’t send it again. Open the connected account’s Sent folder and search for <span class="pr-marker">${esc(d.reconciliationMarker || '')}</span>. If you find it, choose I found it in Sent. ${HELD}`;
283
+ : `FloLess can’t tell whether Gmail accepted this RFI. Don’t send it again. Open the connected account’s Sent folder and search for <span class="pr-marker">${esc(d.reconciliationMarker || '')}</span>. If you find it, choose I found it in Sent. If you don’t, choose I didn’t find it. ${HELD}`;
215
284
  const alert = state.alertFor === rfi.id ? ' role="alert"' : '';
216
285
  if (note) deliveryNote = `<p class="pm-note${pending ? ' pr-delivery-held' : ''}" tabindex="-1" data-pr-delivery-note="${id}"${alert}>${note}</p>`;
217
286
  }
287
+ // #2470 R6.6e: a send from before this RFI last changed still holds it, and offers only Leave it unconfirmed.
288
+ const earlier = (rfi.holdingDeliveries || []).filter((h) => h.stale).map((h) => `<p class="pm-note pr-delivery-held">An earlier Gmail send to ${esc(h.to || '')} (${esc(ago(h.preparedAt, now))}) is still held. Settle it to free this RFI.</p>
289
+ <div class="pm-strip-acts"><button type="button" class="ghost" data-pr-settle="${id}" data-pr-attempt="${esc(h.attemptId)}" data-command-id="shell.project-rfis-gmail-leave-earlier#${esc(h.attemptId)}"
290
+ data-command-instance-label="${id}" aria-label="${esc(`Leave the earlier send of ${rfi.id} unconfirmed`)}" data-tip="Settles that earlier send without recording a send">Leave it unconfirmed…</button></div>`).join('');
291
+ const history = rfi.deliveryHistory;
292
+ let historyHtml = '';
293
+ if (history) {
294
+ const reach = history.mayHaveReached;
295
+ const open = state.historyOpen?.has(rfi.id);
296
+ const lines = history.settled.map((h) => `<li>Gmail send to ${esc(h.to)} · ${esc(ago(h.preparedAt, now))} · not confirmed, ${esc(SETTLED_WORDS[h.choice] || h.choice)}${h.stale ? ' (an earlier send)' : ''}${resendWords(h.resend)}</li>`).join('');
297
+ historyHtml = `<p class="pm-note pr-delivery-held">${esc(reach.to)} ${reach.moreThanOnce ? 'may have received it more than once.' : 'may already have this RFI.'}</p>
298
+ <div class="pm-strip-acts"><button type="button" class="ghost" data-pr-history="${id}" aria-expanded="${open ? 'true' : 'false'}" data-command-id="shell.project-rfi-settled-history#${esc(rfi.id)}" data-command-instance-label="${id}">Not confirmed (${history.settled.length})</button></div>
299
+ ${open ? `<ul class="pg-row-meta pr-settled" aria-label="${esc(`Sends of ${rfi.id} FloLess couldn’t confirm`)}">${lines}</ul>` : ''}`;
300
+ }
301
+ deliveryNote += earlier + historyHtml;
218
302
  const sendButton = rfi.status === 'open' && !pending && rfi.verbs.includes('mark-sent')
219
303
  ? `<button type="button" class="${state.readiness?.status === 'ready' ? 'primary' : 'ghost'}" data-pr-gmail="${id}" data-command-id="shell.project-rfis-gmail-send#${esc(rfi.id)}" ${label}
220
304
  aria-label="${esc(`Send ${rfi.id} with Gmail`)}" data-tip="${esc(elsewhere ? 'A send is in progress' : 'Sends this RFI from your connected Google account')}"${elsewhere}>Send with Gmail…</button>` : '';
221
305
  const recoverButtons = !pending ? '' : d.status === 'prepared'
222
306
  ? `<button type="button" class="primary" data-pr-gmail-continue="${id}" data-pr-attempt="${esc(d.attemptId)}" data-command-id="shell.project-rfis-gmail-continue#${esc(rfi.id)}" ${label}
223
- aria-label="${esc(`Finish sending ${rfi.id} with Gmail`)}" data-tip="Finishes this one send. It never starts a second one."${recovering ? ' aria-busy="true" aria-disabled="true" data-blocked-reason="Finishing this send now."' : ''}>${recovering ? 'Finishing…' : 'Finish sending'}</button>`
307
+ aria-label="${esc(`Finish sending ${rfi.id} with Gmail`)}" data-tip="Finishes this one send. It never starts a second one."${recovering ? ' aria-busy="true" aria-disabled="true" data-blocked-reason="Finishing this send now."' : ''}>${recovering ? 'Finishing…' : 'Finish sending'}</button>${settleButton(rfi, d, 'Something else…')}`
224
308
  : `<button type="button" class="primary" data-pr-gmail-confirm="${id}" data-pr-attempt="${esc(d.attemptId)}" data-command-id="shell.project-rfis-gmail-confirm#${esc(rfi.id)}" ${label}
225
309
  aria-label="${esc(`I found ${rfi.id} in Sent`)}" data-tip="Use only after you found this exact send in the connected account’s Sent folder"${recovering ? ' aria-busy="true" aria-disabled="true" data-blocked-reason="Recording this now."' : ''}>${recovering ? 'Recording…' : 'I found it in Sent'}</button>
226
310
  <button type="button" class="ghost" data-pr-gmail-marker="${id}" data-command-id="shell.project-rfis-gmail-marker#${esc(rfi.id)}" ${label}
227
- aria-label="${esc(`Copy the search text for ${rfi.id}`)}" data-tip="Copies the reference line to search for in Sent">Copy search text</button>`;
311
+ aria-label="${esc(`Copy the search text for ${rfi.id}`)}" data-tip="Copies the reference line to search for in Sent">Copy search text</button>
312
+ ${settleButton(rfi, d, 'I didn’t find it…')}`;
228
313
  const verbButtons = form ? '' : [
229
314
  sendButton, recoverButtons,
230
315
  rfi.status !== 'closed' ? `<button type="button" class="ghost" data-pr-copy="${id}" data-command-id="shell.project-rfi-copy#${esc(rfi.id)}" ${label} aria-label="Copy the email text of ${id}"
@@ -245,7 +330,7 @@
245
330
  drifted ? `<button type="button" class="ghost" data-pr-again="${id}" data-command-id="shell.project-rfi-file-again#${esc(rfi.id)}" ${label}
246
331
  data-tip="Opens New RFI with this title and question and the items that still match">File again from this…</button>` : '',
247
332
  ].join('');
248
- return `<div class="pg-row pr-row" role="listitem"${(state.form?.busy && state.form.rfiId === rfi.id) || recovering ? ' aria-busy="true"' : ''}>
333
+ return `<div class="pg-row pr-row${state.mentioned === rfi.id ? ' is-mentioned' : ''}" role="listitem"${(state.form?.busy && state.form.rfiId === rfi.id) || recovering ? ' aria-busy="true"' : ''}>
249
334
  <div class="pg-row-line"><span class="pg-row-title" tabindex="-1" data-pr-title="${id}">${id} · ${esc(rfi.title)}</span>
250
335
  <span class="pw-chip${rfi.status === 'closed' ? ' is-muted' : ''}">${esc(STATUS[rfi.status] || rfi.status)}</span>${pending ? `<span class="pw-chip is-muted">${d.status === 'prepared' ? 'Unfinished' : 'Not confirmed'}</span>` : ''}</div>
251
336
  <span class="pg-row-meta">${meta.join(' · ')}</span>
@@ -326,6 +411,7 @@
326
411
  mine.view = { status: 'ready', data, error: null };
327
412
  if (mine.form && !data.rfis.some((r) => r.id === mine.form.rfiId)) mine.form = null;
328
413
  paint();
414
+ settleWant();
329
415
  if (data.store === 'ok') {
330
416
  const n = data.rfis.length;
331
417
  if (!mine.quietLoad) announce(n === 0 ? 'No RFIs in this project yet' : `${n} RFI${n === 1 ? '' : 's'}`);
@@ -337,6 +423,7 @@
337
423
  mine.view = { status: gone ? 'gone' : 'failed', data: null,
338
424
  error: said(error, 'FloLess couldn’t read them just now. Check that FloLess is still running, then try again.') };
339
425
  paint();
426
+ settleWant();
340
427
  announce(gone ? 'FloLess couldn’t find this project any more.' : 'FloLess couldn’t load this project’s RFIs.');
341
428
  } finally {
342
429
  mine.inflight = false;
@@ -344,12 +431,60 @@
344
431
  }
345
432
  }
346
433
 
434
+ /**
435
+ * #2874: show one RFI a chat message mentioned. Settles once this project's RFIs are read: the filter widens to All
436
+ * when it hides the RFI, and its row title is focused and outlined. Every outcome is `{ok, said?}`, never a throw; a
437
+ * later request, or the pane drawn again for another project, answers an earlier one `{superseded:true}`.
438
+ */
439
+ function focus(projectId, rfiId) {
440
+ if (!state || state.project.id !== projectId) return Promise.resolve({ ok: false, said: `The RFIs step is not showing this project, so ${rfiId} was not shown.` });
441
+ state.want?.resolve({ superseded: true });
442
+ return new Promise((resolve) => {
443
+ state.want = { rfiId, resolve };
444
+ if (state.view.status !== 'loading' && !state.inflight) settleWant();
445
+ });
446
+ }
447
+
448
+ function settleWant() {
449
+ const want = state?.want;
450
+ if (!want) return;
451
+ state.want = null;
452
+ const { rfiId } = want;
453
+ // A failure is shown on this pane, where the person is looking, as well as returned for the chat's own line.
454
+ const resolve = (outcome) => { if (outcome.ok === false) toast(outcome.said, 'warn'); want.resolve(outcome); };
455
+ const data = state.view.status === 'ready' ? state.view.data : null;
456
+ if (!data || data.store !== 'ok') { resolve({ ok: false, said: `FloLess couldn’t read this project’s RFIs just now, so ${rfiId} was not shown. Click the mention again in a moment.` }); return; }
457
+ const rfi = data.rfis.find((r) => r.id === rfiId);
458
+ if (!rfi) { resolve({ ok: false, reason: 'missing', said: `${rfiId} is no longer one of this project’s RFIs. The list on screen shows the RFIs it has now.` }); return; }
459
+ const widened = !visible([rfi], state.filter).length;
460
+ if (widened) state.filter = 'all';
461
+ state.focusAfter = `[data-pr-title="${CSS.escape(rfiId)}"]`;
462
+ // Outlined for a moment, through any repaint meanwhile (a readiness check, a background read).
463
+ const mine = state;
464
+ mine.mentioned = rfiId;
465
+ if (mine.form) readDraft(); // an open form keeps what was typed across the repaint
466
+ paint();
467
+ const row = state.pane.querySelector(`[data-pr-title="${CSS.escape(rfiId)}"]`)?.closest('.pr-row');
468
+ if (!row) { mine.mentioned = null; resolve({ ok: false, said: `${rfiId} could not be shown. Choose All and find it there.` }); return; }
469
+ row.scrollIntoView?.({ block: 'center' });
470
+ setTimeout(() => {
471
+ if (mine.mentioned !== rfiId) return;
472
+ mine.mentioned = null;
473
+ mine.pane.querySelector(`[data-pr-title="${CSS.escape(rfiId)}"]`)?.closest('.pr-row')?.classList.remove('is-mentioned');
474
+ }, 2400);
475
+ resolve(widened ? { ok: true, said: `Showing all RFIs, so ${rfiId} is in view.` } : { ok: true });
476
+ }
477
+
347
478
  function render(pane, project) {
348
479
  if (!pane || !project) return;
349
480
  const same = state && state.pane === pane && state.project.id === project.id;
481
+ // The same project drawn again (the step shown again while its list loads) keeps the RFI a mention asked for, and
482
+ // shows it once this read is in; another project answers that request as overtaken.
483
+ const want = same ? state.want : null;
484
+ if (!same) state?.want?.resolve({ superseded: true });
350
485
  state = { pane, project, generation: (state?.generation || 0) + 1, view: { status: 'loading', data: null },
351
486
  filter: same ? state.filter : 'open', form: null, inflight: false, again: false, focusAfter: null,
352
- readiness: { status: 'loading' }, recovering: null, alertFor: null };
487
+ readiness: { status: 'loading' }, recovering: null, alertFor: null, want: want ?? null };
353
488
  paint();
354
489
  void load();
355
490
  void checkReadiness();
@@ -393,10 +528,21 @@
393
528
  : verb === 'gmail' ? '.pr-form [data-pr-input="to"], .pr-form [data-pr-gmail-integrations], .pr-form [data-pr-gmail-recheck]' : '.pr-form [data-pr-input]';
394
529
  paint();
395
530
  }
531
+ function openSettle(rfiId, attemptId) {
532
+ const rfi = state.view.data?.rfis.find((r) => r.id === rfiId);
533
+ const held = heldAttempt(rfi, attemptId);
534
+ if (!held) { toast('That send is already settled. The list has been read again.', 'info'); state.quietLoad = true; void load(); return; }
535
+ const ways = SETTLE_WAYS.filter((w) => held[w.allowed]);
536
+ // Only one way (an earlier send): it is the choice. Otherwise nothing is chosen for the person.
537
+ state.form = { rfiId, verb: 'settle', attemptId, key: newKey(), draft: { way: ways.length === 1 ? ways[0].key : '' }, error: null, busy: false, uncertain: false, stale: false };
538
+ state.focusAfter = '.pr-form [data-pr-way][tabindex="0"], .pr-form [data-pr-form-submit]';
539
+ paint();
540
+ }
396
541
  function closeForm() {
397
542
  const f = state.form;
398
543
  state.form = null;
399
- state.focusAfter = !f ? null : f.verb === 'gmail' ? `[data-pr-gmail="${CSS.escape(f.rfiId)}"]` : `[data-pr-verb="${f.verb}"][data-pr-rfi="${CSS.escape(f.rfiId)}"]`;
544
+ state.focusAfter = !f ? null : f.verb === 'settle' ? `[data-pr-settle="${CSS.escape(f.rfiId)}"][data-pr-attempt="${CSS.escape(f.attemptId)}"]`
545
+ : f.verb === 'gmail' ? `[data-pr-gmail="${CSS.escape(f.rfiId)}"]` : `[data-pr-verb="${f.verb}"][data-pr-rfi="${CSS.escape(f.rfiId)}"]`;
400
546
  paint();
401
547
  }
402
548
  function readDraft() {
@@ -410,6 +556,7 @@
410
556
  const f = mine.form;
411
557
  if (!f || f.busy) return;
412
558
  if (f.verb === 'gmail') { void submitGmail(mine, f); return; }
559
+ if (f.verb === 'settle') { void submitSettle(mine, f); return; }
413
560
  if (f.uncertain) { void sendForm(mine, f, f.sent); return; }
414
561
  readDraft();
415
562
  const rfi = mine.view.data.rfis.find((r) => r.id === f.rfiId);
@@ -532,6 +679,89 @@
532
679
  if (status === 'failed') announce(`Gmail didn’t receive ${rfiId}, so nothing was sent.`);
533
680
  }
534
681
 
682
+ // ── The ways out of an unconfirmed send (#2470 R6.6e) ───────────────────────────────────────────────────────
683
+
684
+ /**
685
+ * A Try again answered: the earlier send is settled whatever happened next. When the new send never started (the
686
+ * project is being archived, or it changed), the server's reason is said — the row's own note would only say the
687
+ * send wasn't finished recording, which is not what happened.
688
+ */
689
+ async function settleAgainAnswered(mine, rfiId, res, to) {
690
+ const unfinished = res?.settledAttempt && res?.attempt?.status === 'prepared' && res?.error;
691
+ await settleGmail(mine, rfiId, res, to);
692
+ if (state !== mine || !unfinished) return;
693
+ // "Didn't start" only when the server says so; otherwise Gmail may have taken it and only the record is missing.
694
+ const msg = res.code === 'rfi-gmail-prepared'
695
+ ? `${rfiId}: the earlier send is settled, but the new Gmail send didn’t start. ${res.error}`
696
+ : `${rfiId}: the earlier send is settled. ${res.error}`;
697
+ toast(msg, 'warn'); announce(msg);
698
+ }
699
+
700
+ function submitSettle(mine, f) {
701
+ if (f.uncertain) { void sendSettle(mine, f, f.sent); return; }
702
+ readDraft();
703
+ const d = f.draft;
704
+ const to = String(d.to || '').trim();
705
+ const how = String(d.how || '').trim();
706
+ // Asked, not refused: the button stays live and says what is missing.
707
+ const missing = !d.way ? 'Choose what you want to do first.'
708
+ : d.way === 'sent-another-way' && !d.via ? 'Say how you sent it: by email, or another way.'
709
+ : d.way === 'sent-another-way' && !isAddress(to) ? 'Give the one email address it went to, like name@company.com.'
710
+ : d.way === 'sent-another-way' && d.via === 'other' && !how ? 'Say in a few words how you sent it.' : null;
711
+ if (missing) {
712
+ f.error = missing;
713
+ mine.focusAfter = !d.way ? '.pr-form [data-pr-way][tabindex="0"]' : !d.via ? '.pr-form [data-pr-via][tabindex="0"]' : !isAddress(to) ? '.pr-form [data-pr-input="to"]' : '.pr-form [data-pr-input="how"]';
714
+ paint(); announce(missing); return;
715
+ }
716
+ if (d.way === 'try-again') { openAgain(f); return; }
717
+ const body = { ...identity(), operationKey: f.key };
718
+ if (d.way === 'sent-another-way') { body.to = to; body.via = d.via; if (d.via === 'other') body.how = how; }
719
+ f.sent = { way: d.way, body }; // what Try again resends, unchanged, under the same key
720
+ void sendSettle(mine, f, f.sent);
721
+ }
722
+
723
+ async function sendSettle(mine, f, sent) {
724
+ f.busy = true; f.error = null; mine.focusAfter = '.pr-form [data-pr-form-submit]'; paint();
725
+ const rfiId = f.rfiId;
726
+ try {
727
+ const res = await api(`/api/projects/${encodeURIComponent(target().projectId)}/correspondence-rfis/${encodeURIComponent(rfiId)}/delivery-attempts/${encodeURIComponent(f.attemptId)}/${sent.way}`,
728
+ { method: 'POST', body: JSON.stringify(sent.body) });
729
+ if (state !== mine) return;
730
+ if (sent.way === 'try-again') { await settleAgainAnswered(mine, rfiId, res, sent.body.to); return; }
731
+ mine.form = null; mine.quietLoad = true;
732
+ mine.focusAfter = `[data-pr-title="${CSS.escape(rfiId)}"]`;
733
+ await load();
734
+ if (state !== mine) return;
735
+ const msg = sent.way === 'leave-unconfirmed' ? `${rfiId} left unconfirmed. It’s free again.` : `${rfiId} recorded as sent another way, to ${sent.body.to}.`;
736
+ toast(msg, 'ok'); announce(msg);
737
+ } catch (error) {
738
+ if (state !== mine) return;
739
+ f.busy = false;
740
+ if (sent.way === 'try-again' && error?.body?.attempt) { await settleAgainAnswered(mine, rfiId, error.body, sent.body.to); return; }
741
+ // Someone settled it elsewhere, or it changed: say what the server said and show the list as it now is.
742
+ if (refused(error) && SETTLE_OUT_OF_DATE.has(error.body?.code)) {
743
+ const msg = said(error, `${rfiId} changed since you opened it.`);
744
+ mine.form = null; mine.quietLoad = true;
745
+ mine.focusAfter = `[data-pr-title="${CSS.escape(rfiId)}"]`;
746
+ await load();
747
+ if (state !== mine) return;
748
+ toast(msg, 'warn'); announce(msg);
749
+ return;
750
+ }
751
+ // Gmail not ready answers 503 with nothing written: an answer, so it is said, never taken for a lost one.
752
+ const notReady = error?.body?.code === 'rfi-gmail-not-ready';
753
+ if (notReady && error.body.readiness) mine.readiness = error.body.readiness;
754
+ if (refused(error) || notReady) {
755
+ f.error = said(error, 'FloLess couldn’t do that just now. Try again.');
756
+ f.uncertain = false; f.sent = null; f.key = newKey(); // a refusal: the next try is a new intent
757
+ } else {
758
+ f.uncertain = true; // no answer: same key and body on Try again, so it is done once
759
+ }
760
+ mine.focusAfter = '.pr-form [data-pr-form-submit]';
761
+ paint(); announce(f.uncertain ? 'FloLess didn’t get an answer, so it can’t tell whether that was recorded.' : f.error);
762
+ }
763
+ }
764
+
535
765
  async function recoverGmail(rfiId, attemptId, action) {
536
766
  const mine = state;
537
767
  if (mine.recovering) return;
@@ -652,10 +882,53 @@
652
882
  }
653
883
  const citeKey = (c) => (c.kind === 'knowledge-page' ? `k:${c.slug}` : `d:${c.linkedProjectUuid}:${c.pageId}:${c.sourceHash}`);
654
884
 
885
+ /** Try Gmail again asks first, in a dialog with a tick the person must give (owner ruling, #2470 R6.6e). */
886
+ function openAgain(f) {
887
+ if (!$sheet || !target()) return;
888
+ const rfi = state.view.data?.rfis.find((r) => r.id === f.rfiId);
889
+ const held = heldAttempt(rfi, f.attemptId);
890
+ sheet = { returnFocus: state.pane.querySelector('.pr-form [data-pr-form-submit]') || document.activeElement, mode: 'again', form: f, rfiId: f.rfiId,
891
+ was: held?.to || '', to: f.draft.againTo ?? held?.to ?? '', ticked: false, error: null };
892
+ paintSheet();
893
+ $sheet.classList.add('show');
894
+ requestAnimationFrame(() => $body?.querySelector('[data-pr-again-tick]')?.focus());
895
+ }
896
+ function paintAgain() {
897
+ $title.textContent = 'Send it again?';
898
+ $sub.textContent = `FloLess can’t tell whether Gmail already sent ${sheet.rfiId} to ${sheet.was}. If it did, they will get it twice.`;
899
+ $body.innerHTML = `${sheet.error ? `<div class="pm-note pr-alert" role="alert">${esc(sheet.error)}</div>` : ''}
900
+ <label class="pr-field">Gmail sends a new email to<input type="email" class="pr-input" data-pr-field="to" value="${esc(sheet.to)}" autocomplete="email" data-command-id="shell.project-rfis-gmail-again-to"></label>
901
+ <label class="modal-check"><input type="checkbox" data-pr-again-tick="1" data-command-id="shell.project-rfis-gmail-again-tick"${sheet.ticked ? ' checked' : ''}${sheet.error && !sheet.ticked ? ' aria-invalid="true"' : ''}><span>I understand they may get it twice</span></label>`;
902
+ $foot.innerHTML = `<button type="button" class="ghost" data-pr-sheet-cancel="1" data-command-id="shell.project-rfis-gmail-again-cancel">Cancel</button>
903
+ <button type="button" class="primary" data-pr-again-send="1" data-command-id="shell.project-rfis-gmail-again-send">Send again with Gmail</button>`;
904
+ }
905
+ function sendAgain() {
906
+ sheet.to = String($body.querySelector('[data-pr-field="to"]')?.value || '').trim();
907
+ sheet.ticked = !!$body.querySelector('[data-pr-again-tick]')?.checked;
908
+ // Asked, not refused: the button stays live and says what is missing.
909
+ sheet.error = !isAddress(sheet.to) ? 'Give one email address, like name@company.com.'
910
+ : !sheet.ticked ? 'Tick the box to confirm you understand they may get it twice.' : null;
911
+ if (sheet.error) {
912
+ paintSheet();
913
+ $body.querySelector(isAddress(sheet.to) ? '[data-pr-again-tick]' : '[data-pr-field="to"]')?.focus();
914
+ return;
915
+ }
916
+ const f = sheet.form;
917
+ const to = sheet.to;
918
+ const mine = state;
919
+ const rfi = mine?.view.data?.rfis.find((r) => r.id === f.rfiId);
920
+ closeSheet({ restoreFocus: false });
921
+ if (!mine || mine.form !== f || !rfi) return;
922
+ f.draft.againTo = to;
923
+ f.sent = { way: 'try-again', body: { ...identity(), operationKey: f.key, to: f.draft.againTo, recordRevision: rfi.recordRevision } };
924
+ void sendSettle(mine, f, f.sent);
925
+ }
926
+
655
927
  function paintSheet() {
656
928
  const t = target();
657
929
  if (!sheet || !t) return;
658
930
  if (sheet.mode === 'pick') { paintPicker(); return; }
931
+ if (sheet.mode === 'again') { paintAgain(); return; }
659
932
  $title.textContent = 'New RFI';
660
933
  $sub.textContent = `A question from “${t.name}”. FloLess keeps it; after filing you can send it with Gmail or copy its email text.`;
661
934
  const ro = sheet.uncertain || sheet.busy ? ' readonly' : '';
@@ -815,6 +1088,7 @@
815
1088
  if (t === $sheet) { closeSheet(); return; }
816
1089
  const file = t.closest('[data-pr-sheet-file]');
817
1090
  if (file) { void fileRfi(file.getAttribute('data-pr-sheet-file') === 'sent'); return; }
1091
+ if (t.closest('[data-pr-again-send]')) { sendAgain(); return; }
818
1092
  if (t.closest('[data-pr-sheet-retry]')) { void fileRfi(!!sheet.payload?.markSentTo); return; }
819
1093
  if (t.closest('[data-pr-sheet-edit]')) { sheet.uncertain = false; sheet.key = newKey(); paintSheet(); $body.querySelector('[data-pr-field="title"]')?.focus(); return; }
820
1094
  if (t.closest('[data-pr-sheet-check]')) { closeSheet(); if (state) void load(); return; }
@@ -856,6 +1130,21 @@
856
1130
  if (t.closest('[data-pr-gmail-integrations]')) { readDraft(); if (typeof window.openIntegrations === 'function') window.openIntegrations('google-workspace'); return; }
857
1131
  if (t.closest('[data-pr-gmail-recheck]')) { void checkReadiness(); return; }
858
1132
  if (t.closest('[data-pr-gmail-check]')) { state.form = null; state.quietLoad = true; void load(); return; }
1133
+ const settle = t.closest('[data-pr-settle]');
1134
+ if (settle) { openSettle(settle.getAttribute('data-pr-settle'), settle.getAttribute('data-pr-attempt')); return; }
1135
+ const history = t.closest('[data-pr-history]');
1136
+ if (history) {
1137
+ const rfiId = history.getAttribute('data-pr-history');
1138
+ state.historyOpen ??= new Set();
1139
+ if (state.historyOpen.has(rfiId)) state.historyOpen.delete(rfiId); else state.historyOpen.add(rfiId);
1140
+ readDraft(); state.focusAfter = `[data-pr-history="${CSS.escape(rfiId)}"]`; paint(); return;
1141
+ }
1142
+ const way = t.closest('[data-pr-way]');
1143
+ if (way) { if (state.form?.busy || state.form?.uncertain || way.disabled) return; readDraft(); state.form.draft.way = way.getAttribute('data-pr-way'); state.form.error = null;
1144
+ state.focusAfter = `[data-pr-way="${state.form.draft.way}"]`; paint(); return; }
1145
+ const via = t.closest('[data-pr-via]');
1146
+ if (via) { if (state.form?.busy || state.form?.uncertain || via.disabled) return; readDraft(); state.form.draft.via = via.getAttribute('data-pr-via'); state.form.error = null;
1147
+ state.focusAfter = `[data-pr-via="${state.form.draft.via}"]`; paint(); return; }
859
1148
  const cont = t.closest('[data-pr-gmail-continue]');
860
1149
  if (cont) { if (cont.getAttribute('aria-disabled') !== 'true') void recoverGmail(cont.getAttribute('data-pr-gmail-continue'), cont.getAttribute('data-pr-attempt'), 'continue'); return; }
861
1150
  const confirm = t.closest('[data-pr-gmail-confirm]');
@@ -895,6 +1184,10 @@
895
1184
  sheet.timer = setTimeout(() => void loadCitable(), 200);
896
1185
  }
897
1186
  if (sheet && event.target.closest?.('[data-pr-field]')) event.target.removeAttribute('aria-invalid');
1187
+ if (event.target.matches?.('.pr-form [data-pr-input="how"]')) {
1188
+ const count = event.target.closest('.pr-field')?.querySelector('[data-pr-how-count]');
1189
+ if (count) count.textContent = `${event.target.value.length} of ${HOW_MAX}`;
1190
+ }
898
1191
  });
899
1192
 
900
1193
  document.addEventListener('keydown', (event) => {
@@ -920,9 +1213,9 @@
920
1213
  if (event.key === 'Escape' && state.form && event.target.closest('.pr-form')) { event.preventDefault(); if (!state.form.busy) closeForm(); return; }
921
1214
  if (event.key === 'Enter' && state.form?.verb === 'gmail' && event.target.matches?.('[data-pr-input="to"]')) { event.preventDefault(); void submitForm(); return; }
922
1215
  // The disposition choice is a radio group: arrows move and choose.
923
- const radio = event.target.closest?.('[data-pr-disposition]');
1216
+ const radio = event.target.closest?.('[data-pr-disposition], [data-pr-way], [data-pr-via]');
924
1217
  if (radio && ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(event.key)) {
925
- const radios = [...state.pane.querySelectorAll('[data-pr-disposition]')];
1218
+ const radios = [...radio.closest('[role="radiogroup"]').querySelectorAll('[role="radio"]')];
926
1219
  const i = radios.indexOf(radio);
927
1220
  const next = radios[(i + (event.key === 'ArrowDown' || event.key === 'ArrowRight' ? 1 : radios.length - 1)) % radios.length];
928
1221
  event.preventDefault();
@@ -950,5 +1243,5 @@
950
1243
  window.addEventListener('floless:projects-changed', refresh);
951
1244
  // Back from Integrations (or any window): a send that waited on Google may be possible now.
952
1245
  window.addEventListener('focus', () => { if (state && shown(state.pane) && state.readiness?.status !== 'ready' && !state.form?.busy) void checkReadiness(); });
953
- window.flolessProjectRfis = { render, refresh, html, transferNote };
1246
+ window.flolessProjectRfis = { render, refresh, html, transferNote, focus };
954
1247
  })();
@@ -153,7 +153,7 @@
153
153
  const newBtn = (cls) => `<button type="button" class="ghost ${cls}" data-pw-new="1" data-command-id="shell.project-workflow-new"${view.busyNew ? ' disabled aria-busy="true"' : ''}
154
154
  data-tip="Name a new workflow for this project. AI builds it with you; nothing is made until you confirm.">New workflow…</button>`;
155
155
  const head = `<div class="step-head"><span tabindex="-1" data-pw-heading="1">Workflows</span>${view.status === 'ready' && view.rows.some((w) => w.status !== 'archived') ? newBtn('pw-new') : ''}</div>
156
- <p class="pg-sub">Repeatable checks and reports that belong to this project. Agents, schedules and other workflows that
156
+ <p class="pg-sub">Repeatable workflows that belong to this project, such as checks, reports and exports. Agents, schedules and other workflows that
157
157
  use this project are under <button type="button" class="pw-access" data-pw-access="1" aria-haspopup="dialog" data-command-id="shell.project-workflows-access"
158
158
  data-tip="Shows every Agent, schedule and workflow that reaches into this project">Project access</button>.</p>`;
159
159
  if (view.status === 'loading') return `${head}<p class="pg-loading-line">Loading this project’s workflows…</p>`;