@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
package/dist/web/chat.css CHANGED
@@ -1306,7 +1306,32 @@
1306
1306
  }
1307
1307
  .ai-chat-live-status { min-width: 0; color: var(--text-muted); font: 12px/1.4 var(--ui); }
1308
1308
  .ai-chat-live-status > canvas { flex: none; }
1309
- .ai-chat-live-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1309
+ .ai-chat-live-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
1310
+ /* #2865: while the AI is working, a soft band of the theme's own text colour sweeps left to right
1311
+ across the muted label, then rests. Only colour moves: same box, same glyphs, never dimmer than the
1312
+ muted text it starts from. The phase comes from chat.js (--ai-chat-shimmer-delay), pinned to the page
1313
+ clock, because the feed re-attaches this row on every repaint and would otherwise restart it.
1314
+ A wait for the person, a reconnect or an ended turn drops data-activity and the text is plain. */
1315
+ .ai-chat-live-label[data-activity="working"] {
1316
+ background-image: linear-gradient(90deg, var(--text-muted) 0%, var(--text-muted) 38%, var(--text) 50%, var(--text-muted) 62%, var(--text-muted) 100%);
1317
+ /* 300% puts the band wholly outside the text at both ends, so the rest and the loop jump are invisible. */
1318
+ background-size: 300% 100%;
1319
+ background-repeat: no-repeat;
1320
+ background-position: 100% 0;
1321
+ -webkit-background-clip: text;
1322
+ background-clip: text;
1323
+ color: transparent;
1324
+ -webkit-text-fill-color: transparent;
1325
+ animation: ai-chat-live-shimmer 2600ms linear infinite;
1326
+ animation-delay: var(--ai-chat-shimmer-delay, 0ms);
1327
+ }
1328
+ @keyframes ai-chat-live-shimmer { 0% { background-position: 100% 0; } 75%, 100% { background-position: 0 0; } }
1329
+ @media (prefers-reduced-motion: reduce) {
1330
+ .ai-chat-live-label[data-activity="working"] { animation: none; background: none; color: var(--text-muted); -webkit-text-fill-color: currentColor; }
1331
+ }
1332
+ @media (forced-colors: active) {
1333
+ .ai-chat-live-label[data-activity="working"] { animation: none; background: none; color: CanvasText; -webkit-text-fill-color: currentColor; }
1334
+ }
1310
1335
  .ai-chat-live-dots { display: inline-flex; gap: 3px; }
1311
1336
  .ai-chat-live-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: ai-chat-dot 1.1s ease-in-out infinite; }
1312
1337
  .ai-chat-live-dots i:nth-child(2) { animation-delay: .16s; }
@@ -1521,6 +1546,16 @@
1521
1546
  .ai-chat-mention-status { padding: 6px 8px; color: var(--text-muted); font: 11px/1.4 var(--ui); }
1522
1547
  .ai-chat-attachment.ai-chat-mention .ai-chat-subjects-label { color: var(--text); }
1523
1548
  .ai-chat-message-subjects { align-self: flex-end; max-width: min(100%, 360px); color: var(--text-dim); font: 11px/1.4 var(--ui); text-align: right; overflow-wrap: anywhere; }
1549
+ /* #2874: the @ list's group headings (not options), a long page title on a chip, and a sent message's Mentioned items
1550
+ as inline links that open what they name. An item FloLess could not find stays plain, muted text. */
1551
+ .ai-chat-mention-group { padding: 6px 8px 2px; color: var(--text-dim); font: 600 10px/1.3 var(--ui); letter-spacing: .04em; text-transform: uppercase; }
1552
+ .ai-chat-mention-group:not(:first-child) { border-top: 1px solid var(--border); margin-top: 2px; }
1553
+ .ai-chat-attachment.ai-chat-mention .ai-chat-subjects-label { max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1554
+ .ai-chat-mention-open { display: inline; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline;
1555
+ text-underline-offset: 2px; cursor: pointer; }
1556
+ .ai-chat-mention-open:hover { color: var(--text); }
1557
+ .ai-chat-mention-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px; }
1558
+ .ai-chat-mention-unresolved { color: var(--text-dim); }
1524
1559
 
1525
1560
  /* The Tekla model library carried over from a Graft receipt. It sits in the composer's rigid row,
1526
1561
  above the input, and wraps rather than ellipsising: it states exactly what the binding permits,
package/dist/web/chat.js CHANGED
@@ -586,9 +586,10 @@
586
586
  // #1776/#1859: a drawing read running in this conversation is where a message goes, on any screen.
587
587
  : paintFilterComposer().replyToRead
588
588
  ? READ_REPLY_HINT
589
- // #2438: in a project, @ names a member or sheet.
589
+ // #2438: in a project, @ names a member or sheet; #2874: an RFI or a Knowledge page too (only those in a General one).
590
590
  : state.scope.owner.kind === 'project'
591
- ? 'Enter to send · Shift+Enter for a new line · @ to mention a member or sheet'
591
+ ? (state.mentionGeneral?.[state.scope.owner.projectId] ? 'Enter to send · Shift+Enter for a new line · @ to mention an RFI or Knowledge page'
592
+ : 'Enter to send · Shift+Enter for a new line · @ to mention a member, sheet, RFI or page')
592
593
  : 'Enter to send · Shift+Enter for a new line';
593
594
  if (turnIsVisiblyActive() && !state.followupUnknownId && !hasUnknownFollowup()
594
595
  && state.imageLimitChatId !== state.chat?.chatId) {
@@ -3735,13 +3736,9 @@
3735
3736
  line.textContent = about;
3736
3737
  item.append(line);
3737
3738
  }
3738
- const mentioned = role === 'user' && event.payload?.mentions ? mentionsLine(event.payload.mentions) : '';
3739
- if (mentioned) {
3740
- const line = document.createElement('span'); line.className = 'ai-chat-message-subjects ai-chat-message-mentions';
3741
- line.textContent = mentioned.text;
3742
- line.setAttribute('aria-label', mentioned.spoken);
3743
- item.append(line);
3744
- }
3739
+ // #2874: each item the message mentioned opens what it names.
3740
+ const mentioned = role === 'user' && Array.isArray(event.payload?.mentions) ? mentionsLineElement(event, event.payload.mentions) : null;
3741
+ if (mentioned) item.append(mentioned);
3745
3742
  if (role === 'user' && (event.payload?.followup || event.payload?.deliveryState)) {
3746
3743
  const delivery = followupDelivery(event);
3747
3744
  const deliveryReceipt = [...state.events].reverse().find((candidate) => candidate.type === 'followup-status'
@@ -9397,12 +9394,21 @@
9397
9394
  // #2848: describe only work whose lifetime the provider actually reports. Claude's starts have no
9398
9395
  // matching ends, so its label stays generic (its existing avatar heuristic is separate). Never lift
9399
9396
  // commands, inputs, reasoning or earlier assistant narration into a claim about current work.
9400
- function liveActivityText() {
9401
- if (!turnIsVisiblyActive()) return '';
9402
- if (state.source && state.source.readyState !== 1) return 'Reconnecting to this conversation…';
9397
+ // #2865: `working` says the AI is busy right now, so the label may carry its light sweep. A wait for
9398
+ // the person and a lost connection are not progress, and an ended turn has no label at all.
9399
+ const LIVE_SHIMMER_MS = 2600; // the .ai-chat-live-label[data-activity="working"] animation length in chat.css
9400
+ function liveActivity() {
9401
+ if (!turnIsVisiblyActive()) return { text: '', working: false };
9402
+ if (state.source && state.source.readyState !== 1) return { text: 'Reconnecting to this conversation…', working: false };
9403
9403
  if (state.chat?.state === 'awaiting-approval' || state.chat?.pendingApproval) {
9404
- return state.chat?.pendingApproval?.kind === 'question' ? 'Waiting for your answer…' : 'Waiting for your approval…';
9404
+ return { text: state.chat?.pendingApproval?.kind === 'question' ? 'Waiting for your answer…' : 'Waiting for your approval…', working: false };
9405
9405
  }
9406
+ // Once the person pressed Stop the work is being cancelled, so the label keeps its words but not the sweep.
9407
+ const stopping = typeof stopRequestKey === 'function' && state.pendingStops?.has?.(stopRequestKey());
9408
+ return { text: liveWorkText(), working: !stopping };
9409
+ }
9410
+ function liveActivityText() { return liveActivity().text; }
9411
+ function liveWorkText() {
9406
9412
  if (state.chat?.provider !== 'codex') return 'Processing your request…';
9407
9413
  const running = new Map();
9408
9414
  for (const event of state.events || []) {
@@ -9452,8 +9458,19 @@
9452
9458
  const mood = liveFloMood();
9453
9459
  state.liveFlo.item.dataset.mood = mood;
9454
9460
  state.liveFlo.flo?.setMood(mood, mood === 'working');
9455
- const text = liveActivityText();
9456
- if (state.liveFlo.label.textContent !== text) state.liveFlo.label.textContent = text;
9461
+ const { text, working } = liveActivity();
9462
+ const label = state.liveFlo.label;
9463
+ if (label.textContent !== text) label.textContent = text;
9464
+ // #2865: the sweep is pure CSS on this kept label, switched only when the phase changes. The feed
9465
+ // re-attaches the row on every repaint, which restarts a CSS animation from its first frame, so the
9466
+ // phase is pinned to the page clock: each re-attach resumes exactly where the sweep already was.
9467
+ if (working) {
9468
+ const now = Number(globalThis.document?.timeline?.currentTime ?? globalThis.performance?.now?.() ?? 0) || 0;
9469
+ label.style.setProperty('--ai-chat-shimmer-delay', `-${Math.floor(now % LIVE_SHIMMER_MS)}ms`);
9470
+ }
9471
+ if ((label.dataset.activity === 'working') !== working) {
9472
+ if (working) label.dataset.activity = 'working'; else delete label.dataset.activity;
9473
+ }
9457
9474
  return state.liveFlo.item;
9458
9475
  }
9459
9476
 
@@ -9465,7 +9482,7 @@
9465
9482
  state.liveActivityAnnouncement = null;
9466
9483
  if (state.liveActivityTimer) clearTimeout(state.liveActivityTimer);
9467
9484
  state.liveActivityTimer = null;
9468
- if (state.liveFlo) state.liveFlo.label.textContent = '';
9485
+ if (state.liveFlo) { state.liveFlo.label.textContent = ''; delete state.liveFlo.label.dataset.activity; }
9469
9486
  // The screen-reader announcement is a transient status. Once the durable turn ends,
9470
9487
  // leaving its text behind makes the finished chat sound as though it is still working.
9471
9488
  // Cleared once, when that turn ends — not on every idle repaint: the 5 s poll repaints the
@@ -11021,7 +11038,43 @@
11021
11038
  /** Each conversation keeps its own picks: switching away and back finds them where they were. */
11022
11039
  function setMentions(items) { if (state.chat?.chatId) state.mentions = { ...state.mentions, [state.chat.chatId]: items }; }
11023
11040
  function mentionKey(pick) {
11024
- return pick.kind === 'member' ? JSON.stringify(['member', pick.id, pick.mark]) : JSON.stringify(['sheet', pick.sheet, pick.pageId, pick.sourceHash]);
11041
+ if (pick.kind === 'member') return JSON.stringify(['member', pick.id, pick.mark]);
11042
+ if (pick.kind === 'rfi') return JSON.stringify(['rfi', pick.rfiId]);
11043
+ if (pick.kind === 'kb-page') return JSON.stringify(['kb-page', pick.slug, pick.generationId]);
11044
+ return JSON.stringify(['sheet', pick.sheet, pick.pageId, pick.sourceHash]);
11045
+ }
11046
+ /** #2874: the @ list's groups, in the order they show. */
11047
+ const MENTION_GROUPS = [
11048
+ { kind: 'member', heading: 'Members' }, { kind: 'sheet', heading: 'Sheets' },
11049
+ { kind: 'rfi', heading: 'RFIs' }, { kind: 'kb-page', heading: 'Knowledge pages' },
11050
+ ];
11051
+ /**
11052
+ * The notes of groups that could not offer rows for a reason worth saying (it could not be read, there is no model
11053
+ * yet). A kind that does not apply here — members in a General project, a project with no RFIs or no Knowledge — is
11054
+ * left out, never listed as "nothing". Two groups saying the same thing say it once.
11055
+ */
11056
+ function mentionGroupNotes(groups) {
11057
+ if (!groups) return [];
11058
+ const quiet = new Set(['ok', 'not-steel', 'no-rfis', 'no-knowledge']);
11059
+ const notes = [];
11060
+ for (const { kind } of MENTION_GROUPS) {
11061
+ const group = groups[kind];
11062
+ // A Knowledge list FloLess could only partly read says so, so a page missing from it is not taken as absent.
11063
+ if (group?.status === 'ok' && group.incomplete === true) {
11064
+ notes.push({ kind, note: 'FloLess could not look through every Knowledge page just now, so some may be missing. Type @ again in a moment, or find the page on the Knowledge step.' });
11065
+ continue;
11066
+ }
11067
+ if (!group || quiet.has(group.status) || !group.note) continue;
11068
+ if (!notes.some((n) => n.note === group.note)) notes.push({ kind, note: String(group.note) });
11069
+ }
11070
+ return notes;
11071
+ }
11072
+ /** #2874: an RFI's status in words, and what replaced it, if anything did. */
11073
+ const RFI_STATUS_WORDS = { open: 'Open', sent: 'Sent', answered: 'Answered', resolved: 'Resolved', closed: 'Closed' };
11074
+ function rfiStatusWords(ref) {
11075
+ const status = RFI_STATUS_WORDS[ref.status] || String(ref.status || '');
11076
+ if (ref.supersededBy) return `${status}, replaced by ${ref.supersededBy}`;
11077
+ return ref.closedAs === 'superseded' ? 'Closed as superseded' : status;
11025
11078
  }
11026
11079
 
11027
11080
  /**
@@ -11029,18 +11082,32 @@
11029
11082
  * `all` lists every view (the tooltip); the row shows two and counts the rest, so it never wraps into a paragraph.
11030
11083
  */
11031
11084
  function refDetail(ref, all = false) {
11085
+ if (ref.kind === 'rfi') return `${rfiStatusWords(ref)} · ${ref.question || 'No question recorded'}`;
11086
+ if (ref.kind === 'kb-page') return `Knowledge page · ${ref.slug}`;
11032
11087
  if (ref.kind === 'sheet') return [`Sheet${ref.pageNumber ? `, page ${ref.pageNumber}` : ''}`, `source ${String(ref.sourceHash).slice(0, 8)}`].join(' · ');
11033
11088
  const named = (ref.views || []).map((view) => (view.title ? `${view.sheet} ${view.title}` : view.sheet));
11034
11089
  const shown = all ? named : named.slice(0, 2);
11035
11090
  const views = shown.join(', ') + (named.length > shown.length ? ` +${named.length - shown.length} more` : '');
11036
11091
  return [ref.mark ? null : 'No mark', ref.profile, views ? `on ${views}` : null, `id ${ref.id}`].filter(Boolean).join(' · ');
11037
11092
  }
11093
+ /**
11094
+ * A row of the @ list as a pick (identity only), its label and its tooltip. #2874: a Knowledge page's chip says
11095
+ * "Page ·" before its title, so a page titled "B12 notes" never reads as member B12.
11096
+ */
11038
11097
  function mentionOf(ref) {
11098
+ if (ref.kind === 'rfi') {
11099
+ const pick = { kind: 'rfi', rfiId: ref.rfiId };
11100
+ return { key: mentionKey(pick), pick, label: ref.rfiId, chip: ref.rfiId, tip: `${ref.rfiId} · ${refDetail(ref)}` };
11101
+ }
11102
+ if (ref.kind === 'kb-page') {
11103
+ const pick = { kind: 'kb-page', slug: ref.slug, generationId: ref.generationId };
11104
+ return { key: mentionKey(pick), pick, label: ref.title, chip: `Page · ${ref.title}`, tip: `Knowledge page ${ref.title} · ${ref.slug}` };
11105
+ }
11039
11106
  const pick = ref.kind === 'member'
11040
11107
  ? { kind: 'member', id: ref.id, mark: ref.mark ?? null }
11041
11108
  : { kind: 'sheet', sheet: ref.sheet, pageId: ref.pageId, sourceHash: ref.sourceHash };
11042
11109
  const label = ref.kind === 'member' ? (ref.mark || ref.id) : ref.sheet;
11043
- return { key: mentionKey(pick), pick, label, tip: `${ref.kind === 'member' ? 'Member' : 'Sheet'} ${label} · ${refDetail(ref, true)}` };
11110
+ return { key: mentionKey(pick), pick, label, chip: label, tip: `${ref.kind === 'member' ? 'Member' : 'Sheet'} ${label} · ${refDetail(ref, true)}` };
11044
11111
  }
11045
11112
 
11046
11113
  /** Why a mention did not resolve, in a few words, by what it is. */
@@ -11049,6 +11116,12 @@
11049
11116
  if (mention.reason === 'unreadable') return 'could not be checked';
11050
11117
  if (mention.reason === 'no-model') return 'no model yet';
11051
11118
  if (mention.reason === 'not-steel') return 'not checked, not a steel project';
11119
+ // #2874
11120
+ if (mention.reason === 'rfi-not-found') return 'not one of this project’s RFIs';
11121
+ if (mention.reason === 'rfis-unreadable' || mention.reason === 'knowledge-unreadable') return 'could not be checked';
11122
+ if (mention.reason === 'no-rfis') return 'this project has no RFIs';
11123
+ if (mention.reason === 'page-not-found') return 'not in that version of Knowledge';
11124
+ if (mention.reason === 'not-retained') return 'that version could not be kept';
11052
11125
  return 'not found';
11053
11126
  }
11054
11127
 
@@ -11067,12 +11140,182 @@
11067
11140
  return { text, spoken };
11068
11141
  }
11069
11142
 
11143
+ /**
11144
+ * #2874: the Mentioned line under a sent message, its resolved items buttons that open what they name. Each button
11145
+ * keeps its item's place in the stored list: that index, the message's event and its conversation are all the server
11146
+ * is told, and it opens only what that stored message named. Unresolved items stay text, with their reason.
11147
+ */
11148
+ function mentionsLineElement(event, mentions) {
11149
+ const said = mentionsLine(mentions);
11150
+ if (!said) return null;
11151
+ const line = document.createElement('span'); line.className = 'ai-chat-message-subjects ai-chat-message-mentions';
11152
+ const owner = state.scope?.owner;
11153
+ // A message still on its way has no stored mentions yet: its items open once the server has kept it.
11154
+ const openable = owner?.kind === 'project' && !event.optimistic && typeof event.eventId === 'string' && !event.eventId.startsWith('local:') && !!state.chat?.chatId;
11155
+ // Every item is listed (a message holds at most 20), so each one stays something the person can open.
11156
+ line.append('Mentioned: ');
11157
+ mentions.forEach((m, index) => {
11158
+ if (index) line.append(', ');
11159
+ const name = m.label || m.mark || m.id || m.sheet || m.rfiId || m.slug;
11160
+ if (m.resolved === false || !openable) {
11161
+ const text = Object.assign(document.createElement('span'), { textContent: `${name}${m.resolved === false ? ` (${mentionNotFound(m)})` : ''}` });
11162
+ if (m.resolved === false) text.className = 'ai-chat-mention-unresolved';
11163
+ line.append(text);
11164
+ return;
11165
+ }
11166
+ const kindWords = { member: 'member', sheet: 'sheet', rfi: '', 'kb-page': 'Knowledge page' }[m.kind] ?? '';
11167
+ const what = kindWords ? `${kindWords} ${name}` : name;
11168
+ const open = button(name, `shell.chat-mention-open#${m.kind}`, 'ai-chat-mention-open');
11169
+ open.dataset.commandInstanceLabel = what;
11170
+ open.dataset.tip = m.kind === 'member' ? `Show ${what} in the model` : m.kind === 'rfi' ? `Open ${name} on the RFIs step`
11171
+ : m.kind === 'sheet' ? `Open the picture of ${what}` : `Open ${what} at the version mentioned`;
11172
+ open.setAttribute('aria-label', open.dataset.tip);
11173
+ const chatId = state.chat.chatId, eventId = event.eventId;
11174
+ open.addEventListener('click', () => { void openMentioned({ chatId, eventId, index, mention: m, anchor: open }); });
11175
+ line.append(open);
11176
+ });
11177
+ return line;
11178
+ }
11179
+
11180
+ /** #2874: open one item of a sent message's Mentioned line. Never an error page: every outcome is a sentence. */
11181
+ async function openMentioned({ chatId, eventId, index, mention, anchor }) {
11182
+ const owner = state.scope?.owner;
11183
+ if (owner?.kind !== 'project' || state.chat?.chatId !== chatId) { announce('Open this conversation again to open what it mentioned.'); return; }
11184
+ const name = mention.label || mention.rfiId || mention.mark || mention.id;
11185
+ if (mention.kind === 'member' || mention.kind === 'rfi') {
11186
+ const unreachable = `FloLess could not open ${mention.kind === 'rfi' ? name : `member ${name}`} from here. Open the project from Workspaces, then try again.`;
11187
+ // A failure the place it opens did not show itself (it threw, or nothing answered) is put on screen here too:
11188
+ // the chat's status line is read out, not seen. The editor and the RFIs pane show their own failures.
11189
+ const seen = (text) => { if (typeof window.showToast === 'function') window.showToast(text, 'warn'); };
11190
+ let said, show = false;
11191
+ try {
11192
+ if (typeof window.flolessWorkspaces?.openConnection !== 'function') { announce(unreachable); seen(unreachable); return; }
11193
+ const projectUuid = state.chat?.owner?.projectUuid;
11194
+ const outcome = await window.flolessWorkspaces.openConnection({ projectId: owner.projectId, ...(projectUuid ? { projectUuid } : {}),
11195
+ ...(mention.kind === 'rfi' ? { rfiId: mention.rfiId } : { memberId: mention.id }) });
11196
+ if (outcome?.superseded) return;
11197
+ show = !outcome || (outcome.ok !== true && !outcome.said);
11198
+ said = !outcome ? unreachable : outcome.ok !== true ? (outcome.said || `${mention.kind === 'rfi' ? name : `Member ${name}`} was not shown.`)
11199
+ : outcome.said || (mention.kind === 'rfi' ? `Showing ${name} on the RFIs step.` : `Showing member ${name} in the model.`);
11200
+ } catch (error) {
11201
+ if (error?.plain !== true) console.error('[chat] a mentioned item could not be opened', error);
11202
+ said = error?.plain === true && error.message ? error.message : unreachable;
11203
+ show = true;
11204
+ }
11205
+ if (said) { announce(said); if (show) seen(said); }
11206
+ return;
11207
+ }
11208
+ await openMentionedSource({ chatId, eventId, index, mention, anchor, name, owner });
11209
+ }
11210
+
11211
+ /**
11212
+ * #2874: a mentioned sheet's picture, or a mentioned Knowledge page at the version mentioned, in the source viewer.
11213
+ * A page whose text changed under that version is said to have changed, never shown as the page mentioned.
11214
+ */
11215
+ async function openMentionedSource({ chatId, eventId, index, mention, anchor, name, owner }) {
11216
+ const sheet = mention.kind === 'sheet';
11217
+ const title = sheet ? `Sheet ${name}` : name;
11218
+ const dialog = document.createElement('dialog'); dialog.className = 'ai-chat-source-viewer';
11219
+ dialog.setAttribute('aria-label', title);
11220
+ const head = document.createElement('div'); head.className = 'ai-chat-source-viewer-head';
11221
+ const close = button('Close', 'shell.chat-cite-close', 'ai-chat-source-viewer-close');
11222
+ let picture = null, finished = false, viewport = null;
11223
+ const controller = new AbortController();
11224
+ const finish = () => {
11225
+ if (finished) return;
11226
+ finished = true;
11227
+ controller.abort();
11228
+ if (dialog.open) dialog.close();
11229
+ hide();
11230
+ if (picture) URL.revokeObjectURL(picture);
11231
+ if (anchor?.isConnected) anchor.focus({ preventScroll: true });
11232
+ };
11233
+ close.addEventListener('click', finish);
11234
+ dialog.addEventListener('close', finish);
11235
+ head.append(Object.assign(document.createElement('strong'), { textContent: title }), close);
11236
+ const note = Object.assign(document.createElement('span'), { className: 'ai-chat-source-viewer-note',
11237
+ textContent: sheet ? 'Mentioned in your message. FloLess shows the sheet picture it holds now.' : 'Mentioned in your message, at the version you mentioned.' });
11238
+ const body = document.createElement('div'); body.className = 'ai-chat-source-viewer-body';
11239
+ const status = Object.assign(document.createElement('p'), { className: 'ai-chat-source-viewer-status', textContent: 'Opening…' });
11240
+ status.setAttribute('role', 'status');
11241
+ body.append(status);
11242
+ dialog.append(head, note, body);
11243
+ const hide = showChatViewer(dialog, finish);
11244
+ close.focus({ preventScroll: true });
11245
+ if (sheet) {
11246
+ dialog.classList.add('ai-chat-evidence-viewer');
11247
+ viewport = drawingViewport({ pageBounds: [0, 0, 1, 1] });
11248
+ dialog.insertBefore(viewport.bar, body);
11249
+ body.append(viewport.frame);
11250
+ }
11251
+ const url = `/api/chat/conversations/${encodeURIComponent(chatId)}/mentions/${encodeURIComponent(eventId)}/${index}/${sheet ? 'image' : 'page'}`
11252
+ + `?ownerKind=project&ownerId=${encodeURIComponent(owner.projectId)}`;
11253
+ try {
11254
+ const response = await fetch(url, { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
11255
+ if (finished) return;
11256
+ if (!response.ok) {
11257
+ viewport?.frame.remove(); viewport?.bar.remove();
11258
+ const gone = response.status === 410 || response.status === 404;
11259
+ // A 410 also answers a conversation that moved; only this code says the message and its project still match.
11260
+ const changed = response.status === 410 && (await response.json().catch(() => null))?.code === 'mention-source-changed';
11261
+ if (finished) return;
11262
+ status.textContent = changed ?'This Knowledge page has changed since you mentioned it, so FloLess does not show it as the page you mentioned. You can open the page as it is now.'
11263
+ : response.status === 410 ? 'This conversation has moved, so FloLess could not open what it mentioned here. Open the conversation again, then try again.'
11264
+ : response.status === 404 && sheet ? 'FloLess no longer holds this sheet picture, or this project is no longer the one the message mentioned. Mention the sheet again to see the picture FloLess holds now.'
11265
+ : response.status === 404 ? 'FloLess no longer holds the version of this page you mentioned, or this project is no longer the one the message mentioned. Mention the page again to see it as it is now.'
11266
+ : response.status === 401 || response.status === 403 ? 'This page is no longer signed in to FloLess, so it could not open this. Reload the page, then try again.'
11267
+ : 'FloLess could not open this right now. Try again in a moment.';
11268
+ if (!gone) console.warn('[chat] a mentioned source was refused', response.status);
11269
+ // The way on is the page as it is now, labelled as such, never shown as the version that was mentioned. Only a
11270
+ // changed page says the message and its project still match; a 404 may be a project made again, whose same-named
11271
+ // page is another.
11272
+ if (changed && !sheet && mention.slug) {
11273
+ const now = button('Open the current page in Knowledge', 'shell.chat-mention-open-current-knowledge', 'ai-chat-source-viewer-knowledge');
11274
+ now.addEventListener('click', () => {
11275
+ finish();
11276
+ if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(owner.projectId, mention.slug);
11277
+ else announce('Knowledge is not available on this page.');
11278
+ });
11279
+ dialog.append(now);
11280
+ }
11281
+ return;
11282
+ }
11283
+ if (sheet) {
11284
+ const bytes = await response.blob();
11285
+ if (finished) return;
11286
+ picture = URL.createObjectURL(bytes);
11287
+ const image = Object.assign(document.createElement('img'), { src: picture, alt: title });
11288
+ if (!await viewport.setImage(image, () => !finished, true)) return;
11289
+ status.textContent = 'The sheet picture FloLess holds now.';
11290
+ return;
11291
+ }
11292
+ const { page } = await response.json();
11293
+ if (finished) return;
11294
+ status.textContent = 'The Knowledge page at the version you mentioned.';
11295
+ const article = document.createElement('div'); article.className = 'ai-chat-message-body ai-chat-source-viewer-page';
11296
+ article.innerHTML = markdownHtml(page.body);
11297
+ const knowledge = button('Open in Knowledge', 'shell.chat-cite-open-knowledge', 'ai-chat-source-viewer-knowledge');
11298
+ knowledge.addEventListener('click', () => {
11299
+ finish();
11300
+ if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(page.projectId, page.slug, page.generationId);
11301
+ else announce('Knowledge is not available on this page.');
11302
+ });
11303
+ body.append(article);
11304
+ dialog.append(knowledge);
11305
+ } catch (error) {
11306
+ if (finished) return;
11307
+ console.error('[chat] a mentioned source could not be opened', error);
11308
+ viewport?.frame.remove(); viewport?.bar.remove();
11309
+ status.textContent = 'FloLess could not open this right now. Try again in a moment.';
11310
+ }
11311
+ }
11312
+
11070
11313
  function paintMentionChips() {
11071
11314
  const items = currentMentions();
11072
11315
  for (const item of items) {
11073
11316
  const chip = document.createElement('span'); chip.className = 'ai-chat-attachment ai-chat-mention';
11074
11317
  chip.dataset.mentionKey = item.key;
11075
- const label = button(`@${item.label}`, 'shell.chat-mention', 'ai-chat-subjects-label');
11318
+ const label = button(`@${item.chip || item.label}`, 'shell.chat-mention', 'ai-chat-subjects-label');
11076
11319
  label.dataset.commandInstanceLabel = item.label;
11077
11320
  label.dataset.tip = `${item.tip}. Goes with your next message.`;
11078
11321
  label.setAttribute('aria-label', `${item.tip}, mentioned in your next message`);
@@ -11142,7 +11385,8 @@
11142
11385
  const projectId = state.scope?.owner?.projectId;
11143
11386
  menu.timer = setTimeout(async () => {
11144
11387
  let body = null;
11145
- try { body = await request(`/api/projects/${encodeURIComponent(projectId)}/refs?q=${encodeURIComponent(menu.query)}`); }
11388
+ // #2874: all four kinds, answered in groups; a kind that does not apply to the project says so in its group.
11389
+ try { body = await request(`/api/projects/${encodeURIComponent(projectId)}/refs?q=${encodeURIComponent(menu.query)}&kinds=member,sheet,rfi,kb-page`); }
11146
11390
  catch { body = null; }
11147
11391
  // A newer keystroke, a closed list or another conversation: this answer is for a question nobody is asking now.
11148
11392
  if (state.mentionMenu !== menu || menu.seq !== seq) return;
@@ -11152,15 +11396,27 @@
11152
11396
  else {
11153
11397
  // The row that was active stays active if it is still listed.
11154
11398
  const was = menu.status === 'options' && menu.refs[menu.active] ? mentionOf(menu.refs[menu.active]).key : null;
11155
- menu.refs = Array.isArray(body.refs) ? body.refs : [];
11399
+ menu.refs = Array.isArray(body.refs) ? body.refs.filter((ref) => MENTION_GROUPS.some((g) => g.kind === ref.kind)) : [];
11156
11400
  menu.heldBack = Number(body.heldBack) || 0;
11157
- menu.status = menu.refs.length ? 'options' : 'empty';
11401
+ menu.groups = body.groups && typeof body.groups === 'object' ? body.groups : null;
11402
+ // #2874: which kinds apply here, for the message box's hint (a General project has no members or sheets).
11403
+ if (menu.groups) {
11404
+ const general = menu.groups.member?.status === 'not-steel';
11405
+ const known = state.mentionGeneral?.[projectId];
11406
+ state.mentionGeneral = { ...state.mentionGeneral, [projectId]: general };
11407
+ // The hint is drawn before the list answers: draw it again now it is known, but only while it is that idle
11408
+ // mention hint, never over a notice (a problem, a reconnect, a reply in progress).
11409
+ if (known !== general && /· @ to mention /.test(ui.hint?.textContent || '')) clearReport();
11410
+ }
11411
+ const notes = mentionGroupNotes(menu.groups);
11412
+ if (!menu.refs.length && notes.length) { menu.status = 'note'; menu.note = notes.map((n) => n.note).join(' '); }
11413
+ else menu.status = menu.refs.length ? 'options' : 'empty';
11158
11414
  const kept = was ? menu.refs.findIndex((ref) => mentionOf(ref).key === was) : -1;
11159
11415
  menu.active = menu.refs.length ? Math.max(0, kept) : -1;
11160
11416
  }
11161
11417
  renderMentionMenu();
11162
11418
  announce(menu.status === 'options' ? `${menu.refs.length + menu.heldBack} ${menu.refs.length + menu.heldBack === 1 ? 'match' : 'matches'}`
11163
- : menu.status === 'empty' ? 'No matches' : menu.status === 'error' ? 'FloLess could not list members and sheets' : menu.note);
11419
+ : menu.status === 'empty' ? 'No matches' : menu.status === 'error' ? 'FloLess could not list what you can mention' : menu.note);
11164
11420
  }, 150);
11165
11421
  }
11166
11422
 
@@ -11169,19 +11425,19 @@
11169
11425
  if (!menu) return;
11170
11426
  ui.skills.replaceChildren();
11171
11427
  ui.skills.classList.add('is-mentions');
11172
- ui.skills.setAttribute('aria-label', 'Members and sheets you can mention');
11428
+ ui.skills.setAttribute('aria-label', 'What you can mention');
11173
11429
  const status = (text) => {
11174
11430
  const row = document.createElement('div'); row.className = 'ai-chat-mention-status'; row.setAttribute('role', 'option');
11175
11431
  row.setAttribute('aria-disabled', 'true'); row.textContent = text; ui.skills.append(row);
11176
11432
  };
11177
11433
  let activeId = '';
11178
- if (menu.status === 'loading') status('Looking for members and sheets…');
11434
+ if (menu.status === 'loading') status('Looking for what you can mention…');
11179
11435
  else if (menu.status === 'note') status(menu.note);
11180
11436
  else if (menu.status === 'empty') {
11181
11437
  status(menu.query ? `Nothing in this project is named “${menu.query}”. Type it in your message instead.`
11182
- : 'This project has no members or sheets to mention yet.');
11438
+ : 'Nothing to mention in this project yet. Its members, sheets, RFIs and Knowledge pages appear here.');
11183
11439
  } else if (menu.status === 'error') {
11184
- status('FloLess could not list this project’s members and sheets just now.');
11440
+ status('FloLess could not list what you can mention in this project just now.');
11185
11441
  const retry = button('Try again', 'shell.chat-mention-retry', 'ai-chat-choice');
11186
11442
  retry.id = 'chat-mention-retry'; retry.setAttribute('role', 'option'); retry.setAttribute('aria-selected', 'true');
11187
11443
  retry.addEventListener('pointerdown', (event) => event.preventDefault());
@@ -11189,22 +11445,38 @@
11189
11445
  ui.skills.append(retry);
11190
11446
  activeId = retry.id;
11191
11447
  } else {
11192
- menu.refs.forEach((ref, index) => {
11193
- const item = mentionOf(ref);
11194
- const row = button('', `shell.chat-mention-pick#${item.key}`, 'ai-chat-choice ai-chat-mention-option');
11195
- row.id = `chat-mention-option-${index}`; row.tabIndex = -1;
11196
- row.setAttribute('role', 'option'); row.setAttribute('aria-selected', String(index === menu.active));
11197
- row.dataset.commandInstanceLabel = item.label;
11198
- row.dataset.tip = item.tip;
11199
- const name = document.createElement('span'); name.className = 'ai-chat-mention-name'; name.textContent = item.label;
11200
- const meta = document.createElement('small'); meta.className = 'ai-chat-skill-origin'; meta.textContent = refDetail(ref);
11201
- row.append(name, meta);
11202
- row.addEventListener('pointerdown', (event) => event.preventDefault()); // the message box keeps focus
11203
- row.addEventListener('click', () => pickMention(ref));
11204
- ui.skills.append(row);
11205
- if (index === menu.active) activeId = row.id;
11206
- });
11207
- if (menu.heldBack) status(`${menu.heldBack} more match. Type more of the name to narrow the list.`);
11448
+ // #2874: one heading per kind that has rows or a note, in a fixed order. Headings are not options, so ↑/↓ move
11449
+ // over the rows only and cross from one group to the next; a group that could not be read says so in its place.
11450
+ const notes = mentionGroupNotes(menu.groups);
11451
+ const grouped = !!menu.groups;
11452
+ for (const { kind, heading } of MENTION_GROUPS) {
11453
+ const rows = menu.refs.map((ref, index) => ({ ref, index })).filter(({ ref }) => ref.kind === kind);
11454
+ const note = notes.find((n) => n.kind === kind);
11455
+ if (!rows.length && !note) continue;
11456
+ if (grouped) {
11457
+ const head = Object.assign(document.createElement('div'), { className: 'ai-chat-mention-group', textContent: heading });
11458
+ head.setAttribute('role', 'presentation');
11459
+ ui.skills.append(head);
11460
+ }
11461
+ for (const { ref, index } of rows) {
11462
+ const item = mentionOf(ref);
11463
+ const row = button('', `shell.chat-mention-pick#${item.key}`, 'ai-chat-choice ai-chat-mention-option');
11464
+ row.id = `chat-mention-option-${index}`; row.tabIndex = -1;
11465
+ row.setAttribute('role', 'option'); row.setAttribute('aria-selected', String(index === menu.active));
11466
+ row.setAttribute('aria-setsize', String(menu.refs.length)); row.setAttribute('aria-posinset', String(index + 1));
11467
+ row.dataset.commandInstanceLabel = item.label;
11468
+ row.dataset.tip = item.tip;
11469
+ const name = document.createElement('span'); name.className = 'ai-chat-mention-name'; name.textContent = item.label;
11470
+ const meta = document.createElement('small'); meta.className = 'ai-chat-skill-origin'; meta.textContent = refDetail(ref);
11471
+ row.append(name, meta);
11472
+ row.addEventListener('pointerdown', (event) => event.preventDefault()); // the message box keeps focus
11473
+ row.addEventListener('click', () => pickMention(ref));
11474
+ ui.skills.append(row);
11475
+ if (index === menu.active) activeId = row.id;
11476
+ }
11477
+ if (note) status(note.note);
11478
+ }
11479
+ if (menu.heldBack) status(`${menu.heldBack} more ${menu.heldBack === 1 ? 'match' : 'matches'}. Type more of the name to narrow the list.`);
11208
11480
  }
11209
11481
  ui.skills.hidden = false;
11210
11482
  ui.input.setAttribute('aria-controls', ui.skills.id);
@@ -14395,6 +14667,8 @@
14395
14667
  // even when a request from a conversation the person has left is the one that just settled.
14396
14668
  function paintStopState() {
14397
14669
  const pending = state.chat && state.pendingStops.get(stopRequestKey());
14670
+ // #2865: the kept live row stops its sweep the moment Stop is pressed, without waiting for a repaint.
14671
+ if (state.liveFlo && turnIsVisiblyActive()) renderLiveStatus();
14398
14672
  for (const control of [ui.stop, ui.recoveryStop]) {
14399
14673
  control.disabled = Boolean(pending);
14400
14674
  if (pending) {
@@ -16021,10 +16295,12 @@
16021
16295
  ui.input.focus();
16022
16296
  }
16023
16297
 
16024
- async function openDraft(draft) {
16298
+ async function openDraft(draft, { ownerKey = null } = {}) {
16025
16299
  if (typeof draft !== 'string' || !draft.trim()) return;
16026
16300
  await refreshScope();
16027
16301
  if (!state.scope?.owner) throw new Error('Open a project or workflow before asking AI Chat about a local tool.');
16302
+ // #2764: a request written for one conversation is never put into another the person opened while it was on its way.
16303
+ if (ownerKey && scopeKey(state.scope) !== ownerKey) throw new Error('AI Chat moved to another conversation.');
16028
16304
  window.flolessBridge?.revealAiChat?.();
16029
16305
  ui.tab.click();
16030
16306
  if (!state.chat || state.chat.activeTurn || state.chat.archivedAt || state.chat.state === 'recovery') {
@@ -16265,6 +16541,8 @@
16265
16541
  // (the upload modal, Requests) says what happened and what to do next instead of a generic toast (#1779).
16266
16542
  describeError: errorMessage,
16267
16543
  currentProvider: () => state.chat?.provider ?? null,
16544
+ // #2926: the conversation on screen, so the Drawing Filter's Flo knows a question shown here is its read's.
16545
+ currentChatId: () => state.chat?.chatId ?? null,
16268
16546
  // The project this panel's conversations belong to; an object card offers Show in chat only for it (#1653).
16269
16547
  scopeProjectId: () => (state.scope?.owner?.kind === 'project' ? state.scope.owner.projectId : null),
16270
16548
  // The Knowledge step's "Ask AI to index" (#2399 slice 0b): the person's own draft in the message box; never sent.
@@ -241,6 +241,41 @@
241
241
  guidance: 'on-demand',
242
242
  });
243
243
 
244
+ // #2926: Flo on the stage while a drawing read runs. It shows only what FloLess saw the AI do: the sheet pictures
245
+ // it asked for, and its own progress sentence.
246
+ def('filter.flo-toggle', {
247
+ label: 'Show Flo',
248
+ actsOn: 'Shows or hides Flo, who marks the part of the drawing the AI is reading',
249
+ group: 'On the Drawing Filter canvas',
250
+ persistence: 'local',
251
+ interaction: 'instant',
252
+ risk: [],
253
+ guidance: 'on-demand',
254
+ why: 'While a drawing read runs, Flo stands beside the part of the sheet the AI asked FloLess to show it, and says what the AI is doing. When the AI has asked you something, Flo moves to the corner and says it is waiting for your answer. It is on until you turn it off, and stays off on this computer. It changes nothing in the filter.',
255
+ });
256
+
257
+ def('filter.flo-show-sheet', {
258
+ label: 'Show the sheet Flo is reading',
259
+ actsOn: 'Opens the sheet the AI is reading now',
260
+ group: 'On the Drawing Filter canvas',
261
+ persistence: 'local',
262
+ interaction: 'instant',
263
+ risk: [],
264
+ guidance: 'on-demand',
265
+ why: 'Shown in Flo’s bubble while the AI reads a sheet you are not looking at. The view never changes by itself: this is the way to follow it. Your filter is untouched.',
266
+ });
267
+
268
+ def('filter.flo-answer', {
269
+ label: 'Answer in AI Chat',
270
+ actsOn: 'Opens the AI’s question in AI Chat',
271
+ group: 'On the Drawing Filter canvas',
272
+ persistence: 'none',
273
+ interaction: 'instant',
274
+ risk: [],
275
+ guidance: 'on-demand',
276
+ why: 'Shown in Flo’s bubble while the drawing read waits for your answer in AI Chat. It opens that conversation, where the question is; it answers nothing for you.',
277
+ });
278
+
244
279
  def('filter.place-clear', {
245
280
  label: 'Clear the marked place',
246
281
  actsOn: 'Removes the outline of a place AI Chat opened on this drawing',