@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
@@ -283,6 +283,8 @@
283
283
  // mode — and the markup stays the one place that sentence is written.
284
284
  const WORKSPACE_TAB_TIP = $workspaceTab?.getAttribute('data-tip') || '';
285
285
  const $landing = document.getElementById('ws-landing');
286
+ // #2866: a changed Sort by choice repaints the landing (renderLanding keeps the search, focus, scroll and sections).
287
+ window.flolessLandingSort?.onChange('workspaces', () => { if (!$landing.hidden) renderLanding(); });
286
288
  // The landing search's query. Kept here, not only in the input, because renderLanding() rebuilds the
287
289
  // whole landing with innerHTML on background refreshes; applyMode() empties it on each fresh visit.
288
290
  let landingQuery = '';
@@ -792,6 +794,7 @@
792
794
  { key: 'rfis', label: 'RFIs' }, // #2470 R6.6c: owner ruling 2026-10-25, right after Model
793
795
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages; #2568: just before Exports (both are output)
794
796
  { key: 'exports', label: 'Exports' },
797
+ { key: 'workflows', label: 'Workflows' }, // #2470 R6.2b: the workflows this project owns; owner ruling 2026-10-29, right after Exports
795
798
  { key: 'history', label: 'History' },
796
799
  ],
797
800
  diff: true, // steel semantic diff expander
@@ -842,6 +845,7 @@
842
845
  { key: 'model', label: 'Traced' }, // reuse the 'model' frame slot; label "Traced"
843
846
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages; #2568: just before Exports (both are output)
844
847
  { key: 'exports', label: 'Exports' },
848
+ { key: 'workflows', label: 'Workflows' }, // #2470 R6.2b: the workflows this project owns; owner ruling 2026-10-29, right after Exports
845
849
  { key: 'history', label: 'History' },
846
850
  ],
847
851
  diff: false,
@@ -872,8 +876,10 @@
872
876
  { key: 'knowledge', label: 'Knowledge' },
873
877
  { key: 'drawings', label: 'Source' },
874
878
  { key: 'model', label: 'Model' },
875
- { key: 'history', label: 'History' },
876
879
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
880
+ // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
881
+ { key: 'workflows', label: 'Workflows' },
882
+ { key: 'history', label: 'History' },
877
883
  ],
878
884
  diff: false,
879
885
  exports: [],
@@ -900,8 +906,10 @@
900
906
  { key: 'knowledge', label: 'Knowledge' },
901
907
  { key: 'drawings', label: 'Source' },
902
908
  { key: 'model', label: 'Model' },
903
- { key: 'history', label: 'History' },
904
909
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
910
+ // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
911
+ { key: 'workflows', label: 'Workflows' },
912
+ { key: 'history', label: 'History' },
905
913
  ],
906
914
  diff: false,
907
915
  exports: [],
@@ -964,8 +972,10 @@
964
972
  steps: [
965
973
  { key: 'knowledge', label: 'Knowledge' }, // the client's standards are knowledge, as for every app
966
974
  { key: 'model', label: 'Checker' },
967
- { key: 'history', label: 'History' },
968
975
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
976
+ // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
977
+ { key: 'workflows', label: 'Workflows' },
978
+ { key: 'history', label: 'History' },
969
979
  ],
970
980
  diff: false,
971
981
  exports: [],
@@ -2080,6 +2090,7 @@
2080
2090
  }
2081
2091
  const wasUnits = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
2082
2092
  const wasApproved = cached.approvedAt;
2093
+ const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
2083
2094
  Object.assign(cached, fresh, {
2084
2095
  displayUnits: fresh.displayUnits === 'mm' ? 'mm' : 'ft-in',
2085
2096
  registrationState: registration.status,
@@ -2090,6 +2101,12 @@
2090
2101
  });
2091
2102
  if (!Object.hasOwn(fresh, 'approvedAt')) delete cached.approvedAt;
2092
2103
  patchRegisteredCard(cached);
2104
+ // #2866: the patch updates the card in place; when it changed what the page is sorted by, repaint so the card
2105
+ // moves to its place (renderLanding keeps focus, scroll, search and sections). The name always counts: a date
2106
+ // sort orders undated cards and equal dates by name.
2107
+ { const sort = window.flolessLandingSort?.get('workspaces');
2108
+ const key = sort?.field === 'created' ? 'createdAt' : sort?.field === 'modified' ? 'updatedAt' : 'name';
2109
+ if (sort && !$landing.hidden && !current && (wasSortKeys.name !== cached.name || wasSortKeys[key] !== cached[key])) renderLanding(); }
2093
2110
  if (navigation !== openNavSeq || current?.registrationId !== registrationId) continue;
2094
2111
  const units = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
2095
2112
  Object.assign(current, cached);
@@ -2734,6 +2751,23 @@
2734
2751
  const rootPath = rootState && rootState.root && rootState.root.path;
2735
2752
  const rootUnavailable = !!rootState && rootState.available === false;
2736
2753
  const folderName = window.flolessWorkspaceRoot ? window.flolessWorkspaceRoot.name() : 'Workspace directory';
2754
+ // #2866: the page's Sort by choice orders the cards inside each module section (and the Archived list); the
2755
+ // sections themselves keep their order. Dates are the project's own createdAt/updatedAt; an offline project with
2756
+ // no last-known record has neither and is listed last, by name, rather than given an invented date.
2757
+ const sorter = window.flolessLandingSort || null;
2758
+ const sortState = sorter ? sorter.get('workspaces') : null;
2759
+ const sortKeys = (p) => ({ name: p.name, id: p.registrationId || p.id, created: p.createdAt, modified: p.updatedAt });
2760
+ const sorted = (list) => (sorter ? sorter.sort(list, sortState, sortKeys) : list);
2761
+ /** The card's time segment: "2 h ago" (its last change) as always, or, while the page is sorted by date created,
2762
+ * the date it was created. A project with no recorded creation date shows no time rather than another date. The
2763
+ * created date is not a `.t`: patchRegisteredCard rewrites `.t` with the change time. */
2764
+ function projectCardTime(p) {
2765
+ if (sorter && sortState?.field === 'created') {
2766
+ const text = sorter.cardDate(sortState, p.createdAt, p.updatedAt);
2767
+ return text ? `<span class="ws-sep"> · </span><span class="t-created">${escapeHtml(text)}</span>` : '';
2768
+ }
2769
+ return `<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span>`;
2770
+ }
2737
2771
  let html = `<div class="ws-head"><div class="ws-head-text"><h2>Workspaces</h2>` +
2738
2772
  `<div class="ws-sub">${rootUnavailable ? 'Workspace directory unavailable. Choose another folder to continue.' : 'Open a project to view its drawings, model, Knowledge and history.'}</div></div>` +
2739
2773
  `<div class="ws-head-actions">` +
@@ -2741,6 +2775,7 @@
2741
2775
  (!rootUnavailable && projects.length
2742
2776
  ? `<input type="search" id="ws-landing-search" class="ws-landing-search" data-command-id="shell.project-list-search" placeholder="Search projects" aria-label="Search projects by name, description, kind or workflow" autocomplete="off" spellcheck="false" value="${escapeAttr(landingQuery)}">`
2743
2777
  : '') +
2778
+ (!rootUnavailable && (projects.length || archived.length) && sorter ? sorter.controlHtml('workspaces') : '') +
2744
2779
  `<button type="button" class="ws-import-btn ws-folder-btn${rootUnavailable ? ' is-unavailable' : ''}" id="ws-workspace-folder" data-command-id="menu.workspace-folder" data-tip="${escapeAttr(rootPath || 'Choose the Workspace directory FloLess reads for projects and workflows')}">Workspace directory · ${escapeHtml(rootUnavailable ? 'unavailable' : folderName)}</button>` +
2745
2780
  `${rootUnavailable ? '' : '<button type="button" class="ws-import-btn" id="ws-import-project" data-command-id="shell.project-import" data-tip="Restore a project from an exported .zip file or a zipped project folder">↓ Import project…</button>'}</div></div>`;
2746
2781
  html += '<div class="ws-folder-review-note" id="ws-folder-review-note" hidden></div>';
@@ -2767,9 +2802,11 @@
2767
2802
  const expanded = landingQuery.trim() ? (projectGroupSearchOverrides.get(group.key) ?? true) : projectGroupExpanded(group.key);
2768
2803
  html += `<section class="ws-project-section" data-module="${escapeAttr(group.key)}">` +
2769
2804
  `<h3 class="ws-project-heading"><button type="button" class="ws-project-group-toggle" data-project-group-toggle="${escapeAttr(group.key)}" data-command-id="shell.project-group-toggle#${escapeAttr(group.key)}" data-command-instance-label="${escapeAttr(group.label)}" aria-controls="${groupGridId}" aria-expanded="${expanded}" data-tip="${escapeAttr((expanded ? 'Collapse ' : 'Expand ') + group.label)}"><span class="ws-project-chevron" aria-hidden="true">›</span><span class="ws-project-group-label">${escapeHtml(group.label)}</span> ` +
2770
- `<span class="ws-project-count">${group.projects.length} ${group.projects.length === 1 ? 'project' : 'projects'}</span></button></h3>` +
2805
+ `<span class="ws-project-count">${group.projects.length} ${group.projects.length === 1 ? 'project' : 'projects'}</span>` +
2806
+ (sorter ? `<span class="ls-undated">${escapeHtml(sorter.undatedNote(sorter.undatedCount(group.projects, sortState, sortKeys), group.projects.length, sortState))}</span>` : '') +
2807
+ `</button></h3>` +
2771
2808
  `<div class="ws-grid" id="${groupGridId}"${expanded ? '' : ' hidden'}>`;
2772
- for (const p of group.projects) {
2809
+ for (const p of sorted(group.projects)) {
2773
2810
  const d = wsDescOf(p);
2774
2811
  const displayApp = projectAppName(p);
2775
2812
  const projectCapability = d && d.projectCapability ? d.projectCapability : '';
@@ -2796,7 +2833,7 @@
2796
2833
  (p.importedMidSave ? `<span class="ws-meta ws-unverified" data-tip="${escapeAttr(UNVERIFIED_IMPORT_TIP)}">Imported mid-save · not verified. Export again on the source computer.</span>` : '') +
2797
2834
  `<span class="ws-meta ws-registration-status"${p.registrationState === 'unavailable' ? '' : ' hidden'}>${escapeHtml(p.registrationReason || 'Project folder unavailable. Locate or restore it.')}</span>` +
2798
2835
  `<span class="ws-meta ws-registration-location-note"${p.registrationState !== 'unavailable' && p.registrationLocationWarning ? '' : ' hidden'}>${escapeHtml(p.registrationLocationWarning || '')}</span>` +
2799
- `<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}<span class="ws-sep"> · </span><span class="t">${escapeHtml(relAgo(p.updatedAt))}</span></span></span>` +
2836
+ `<span class="ws-meta ws-meta-app"><span class="ws-meta-kind">${escapeHtml(displayApp)}</span>${wfName}${projectCardTime(p)}</span></span>` +
2800
2837
  `<button type="button" class="ws-kebab" data-kebab="${escapeAttr(p.id)}"${p.registrationState === 'unavailable' ? ` data-command-id="shell.project-registration-review#${escapeAttr(p.registrationId)}" data-command-instance-label="${escapeAttr(p.name)}"` : ''} aria-label="${p.registrationState === 'unavailable' ? 'Review project folder' : 'Project actions'}" data-tip="${p.registrationState === 'unavailable' ? 'Review project folder' : p.importedMidSave ? 'Rename · Thumbnail · Mark as checked · Duplicate · Export · Archive' : 'Rename · Thumbnail · Duplicate · Export · Archive'}">⋯</button>` +
2801
2838
  `</span></div>`;
2802
2839
  }
@@ -2840,7 +2877,7 @@
2840
2877
  // Demoted rows (muted, no thumb) read as "put away"; each offers Restore + a guarded Delete.
2841
2878
  if (archived.length) {
2842
2879
  let rows = '';
2843
- for (const p of archived) {
2880
+ for (const p of sorted(archived)) {
2844
2881
  const displayApp = projectAppName(p);
2845
2882
  // Tooltip only, deliberately: the Trash is a scan-and-act list where the user's own project
2846
2883
  // NAME is the identifier (it doesn't even carry projectCapability), and a third clause on an
@@ -2862,7 +2899,9 @@
2862
2899
  `</div>`;
2863
2900
  }
2864
2901
  html += `<details class="ws-archived">` +
2865
- `<summary class="ws-archived-summary"><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>Archived <span class="ws-archived-count">${archived.length}</span></summary>` +
2902
+ `<summary class="ws-archived-summary"><span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span>Archived <span class="ws-archived-count">${archived.length}</span>` +
2903
+ (sorter && sorter.undatedCount(archived, sortState, sortKeys) ? ` <span class="ls-undated">${escapeHtml(sorter.undatedNote(sorter.undatedCount(archived, sortState, sortKeys), archived.length, sortState))}</span>` : '') +
2904
+ `</summary>` +
2866
2905
  `<div class="ws-archived-list">${rows}</div>` +
2867
2906
  `</details>`;
2868
2907
  }
@@ -3811,6 +3850,9 @@
3811
3850
  const $projectSetupKickoffNote = document.getElementById('project-setup-kickoff-note');
3812
3851
  const $projectSetupBuild = document.getElementById('project-setup-build');
3813
3852
  const $projectSetupQuickTerms = document.getElementById('project-setup-quick-terms');
3853
+ const $projectSetupQuickTermsTail = document.getElementById('project-setup-quick-terms-tail');
3854
+ const $projectSetupFilter = document.getElementById('project-setup-filter');
3855
+ const $projectSetupExclusions = document.getElementById('project-setup-exclusions');
3814
3856
  const $projectSetupBuildLocked = document.getElementById('project-setup-build-locked');
3815
3857
  const $projectSetupCancel = document.getElementById('project-setup-cancel');
3816
3858
  const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
@@ -4070,14 +4112,75 @@
4070
4112
  else button.removeAttribute('aria-disabled');
4071
4113
  }
4072
4114
  $projectSetupQuickTerms.hidden = mode !== 'quick';
4115
+ // #2521 row 2c: who decides the Drawing Filter, asked only with Quick (Precise always waits for the person's Save).
4116
+ const filter = projectSetupFilterChoice(state);
4117
+ if ($projectSetupFilter) {
4118
+ $projectSetupFilter.hidden = mode !== 'quick';
4119
+ for (const button of $projectSetupFilter.querySelectorAll('[data-filter-choice]')) {
4120
+ button.setAttribute('aria-pressed', String(button.dataset.filterChoice === filter));
4121
+ if (locked) button.setAttribute('aria-disabled', 'true');
4122
+ else button.removeAttribute('aria-disabled');
4123
+ }
4124
+ }
4125
+ // Revision 3 (owner ruling 2026-10-26): who approves what the read leaves out, asked only while the AI chooses the Filter.
4126
+ const exclusions = projectSetupExclusionsChoice(state);
4127
+ if ($projectSetupExclusions) {
4128
+ $projectSetupExclusions.hidden = mode !== 'quick' || filter !== 'ai';
4129
+ for (const button of $projectSetupExclusions.querySelectorAll('[data-exclusions-choice]')) {
4130
+ button.setAttribute('aria-pressed', String(button.dataset.exclusionsChoice === exclusions));
4131
+ if (locked) button.setAttribute('aria-disabled', 'true');
4132
+ else button.removeAttribute('aria-disabled');
4133
+ }
4134
+ }
4135
+ if ($projectSetupQuickTermsTail) {
4136
+ $projectSetupQuickTermsTail.textContent = PROJECT_SETUP_TERMS_TAIL[filter === 'ai' && exclusions === 'person' ? 'aiKeep' : filter];
4137
+ }
4073
4138
  $projectSetupBuildLocked.hidden = !locked;
4074
4139
  if (shown && mode === 'quick') $projectSetupCreateOnly.setAttribute('aria-describedby', 'project-setup-quick-create-only');
4075
4140
  else $projectSetupCreateOnly.removeAttribute('aria-describedby');
4076
4141
  }
4077
4142
 
4143
+ /**
4144
+ * #2521 row 2c: the Drawing Filter choice that goes with Quick: 'ai' only when the person pressed "Let the AI choose",
4145
+ * else 'person'. Once sent it is the sent one, as for the Model choice; with Precise there is none to send.
4146
+ */
4147
+ function projectSetupFilterChoice(state) {
4148
+ const value = state.submissionId ? state.sentFilterChoice : state.filterChoice;
4149
+ return value === 'ai' ? 'ai' : 'person';
4150
+ }
4151
+ /**
4152
+ * Revision 3: who approves what the read leaves out when the AI chooses the Filter: 'ai' (the default, "it must be
4153
+ * quick") unless the person pressed "I'll approve them myself". Once sent it is the sent one.
4154
+ */
4155
+ function projectSetupExclusionsChoice(state) {
4156
+ const value = state.submissionId ? state.sentExclusionsChoice : state.exclusionsChoice;
4157
+ return value === 'person' ? 'person' : 'ai';
4158
+ }
4159
+ /** The Quick terms' last sentence, which follows the Filter choice so it never says the person decides what the AI does. */
4160
+ const PROJECT_SETUP_TERMS_TAIL = {
4161
+ person: 'The AI never approves anything: you still decide on the Drawing Filter and on the review.',
4162
+ // It does approve what that Filter leaves out of the read, so "never approves anything" would be untrue here (code review).
4163
+ ai: 'The AI chooses the Drawing Filter, including what the read leaves out, recorded and labelled as its own; you still decide on the review.',
4164
+ aiKeep: 'The AI chooses the Drawing Filter, recorded and labelled as its own; you approve what the read leaves out, and you still decide on the review.',
4165
+ };
4166
+ function chooseProjectSetupFilter(button) {
4167
+ if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
4168
+ projectSetupState.filterChoice = button.dataset.filterChoice === 'ai' ? 'ai' : 'person';
4169
+ // The exclusion choice belongs to the AI's Filter choice: the person's own Save drops it, back to the quick default.
4170
+ if (projectSetupState.filterChoice === 'person') projectSetupState.exclusionsChoice = 'ai';
4171
+ renderProjectSetup();
4172
+ }
4173
+ function chooseProjectSetupExclusions(button) {
4174
+ if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
4175
+ projectSetupState.exclusionsChoice = button.dataset.exclusionsChoice === 'person' ? 'person' : 'ai';
4176
+ renderProjectSetup();
4177
+ }
4178
+
4078
4179
  function chooseProjectSetupBuildMode(button) {
4079
4180
  if (!button || !projectSetupState || projectSetupState.busy || projectSetupState.submissionId) return;
4080
4181
  projectSetupState.buildMode = button.dataset.buildMode === 'quick' ? 'quick' : 'precise';
4182
+ // #2521 row 2c: the Filter choice belongs to Quick: Precise drops it, and Quick again starts from the person's Save.
4183
+ if (projectSetupState.buildMode === 'precise') { projectSetupState.filterChoice = 'person'; projectSetupState.exclusionsChoice = 'ai'; }
4081
4184
  renderProjectSetup();
4082
4185
  if (projectSetupState.buildMode === 'quick') $projectSetupQuickTerms.scrollIntoView?.({ block: 'nearest' });
4083
4186
  }
@@ -4272,6 +4375,9 @@
4272
4375
  state.snapshots = snapshots;
4273
4376
  // #2521 row 7a: the choice is settled with the first send and every retry repeats it.
4274
4377
  if (!state.submissionId) state.sentBuildMode = projectSetupBuildShown(state, provider) && state.buildMode === 'quick' ? 'quick' : null;
4378
+ // #2521 row 2c: the Filter choice is sent only with Quick, and fixed with the first send like the Model choice.
4379
+ if (!state.submissionId) state.sentFilterChoice = state.sentBuildMode === 'quick' && state.filterChoice === 'ai' ? 'ai' : null;
4380
+ if (!state.submissionId) state.sentExclusionsChoice = state.sentFilterChoice === 'ai' ? (state.exclusionsChoice === 'person' ? 'person' : 'ai') : null;
4275
4381
  const submissionId = state.submissionId || crypto.randomUUID();
4276
4382
  state.submissionId = submissionId;
4277
4383
  rememberProjectChatIntake(submissionId);
@@ -4283,6 +4389,8 @@
4283
4389
  snapshots,
4284
4390
  provider,
4285
4391
  ...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
4392
+ ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
4393
+ ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
4286
4394
  });
4287
4395
  const project = result.project;
4288
4396
  state.project = project;
@@ -4385,6 +4493,10 @@
4385
4493
  environment: null,
4386
4494
  // #2521 row 7a: Precise unless the person presses Quick; what was sent is kept in `sentBuildMode`.
4387
4495
  buildMode: 'precise',
4496
+ // #2521 row 2c: the person's own Filter Save unless they press "Let the AI choose" (with Quick only).
4497
+ filterChoice: 'person',
4498
+ // Revision 3: with "Let the AI choose", the AI also approves what the read leaves out unless the person keeps it.
4499
+ exclusionsChoice: 'ai',
4388
4500
  directory: null,
4389
4501
  name: '',
4390
4502
  nameDirty: false,
@@ -4442,7 +4554,11 @@
4442
4554
  renderProjectSetup();
4443
4555
  });
4444
4556
  $projectSetupBuild?.addEventListener('click', (event) => {
4445
- chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
4557
+ const exclusionsButton = event.target.closest('[data-exclusions-choice]');
4558
+ if (exclusionsButton) { chooseProjectSetupExclusions(exclusionsButton); return; }
4559
+ const filterButton = event.target.closest('[data-filter-choice]');
4560
+ if (filterButton) chooseProjectSetupFilter(filterButton);
4561
+ else chooseProjectSetupBuildMode(event.target.closest('[data-build-mode]'));
4446
4562
  });
4447
4563
  $projectSetupProvider?.addEventListener('click', (event) => {
4448
4564
  chooseProjectSetupProvider(event.target.closest('[data-chat-provider]'));
@@ -5751,6 +5867,90 @@
5751
5867
  };
5752
5868
  }
5753
5869
 
5870
+ // #2926: no picture asked for in this long, and a conversation that is not running, means a chat-run read is not
5871
+ // reading. A terminal-run read has only its pictures to prove that once its progress record is stale.
5872
+ const FLO_FRESH_WORK_MS = 2 * 60_000;
5873
+ const FLO_HASH = /^[0-9a-f]{64}$/;
5874
+ function floLookOk(l) {
5875
+ return !!l && typeof l === 'object' && typeof l.pageId === 'string' && FLO_HASH.test(l.sourceHash)
5876
+ && Number.isSafeInteger(l.pageNumber) && l.pageNumber >= 1 && Number.isSafeInteger(l.part) && l.part >= 0 && l.part <= 9
5877
+ && Number.isSafeInteger(l.seq) && Number.isFinite(l.ageMs) && l.ageMs >= 0
5878
+ && (l.rect === null || (Array.isArray(l.rect) && l.rect.length === 4 && l.rect.every((v) => Number.isFinite(v) && v >= 0 && v <= 1)
5879
+ && l.rect[2] > l.rect[0] && l.rect[3] > l.rect[1]));
5880
+ }
5881
+
5882
+ /**
5883
+ * #2926: what the Drawing Filter's Flo shows for the read the progress strip speaks for, from that read's own
5884
+ * signals only. `reading` while it is evidently working (with the sheet pictures it last asked for), `waiting`
5885
+ * only while the AI has really asked the person something, and `off` otherwise, with the reason.
5886
+ *
5887
+ * `view` is drawingProgressView()'s projection of the same request (null when the strip shows no live progress).
5888
+ * ctx: { contactLost, chatAsking (AI Chat shows a question or approval on this read's conversation), pendingSave }.
5889
+ */
5890
+ function filterFloState(req, view, ctx) {
5891
+ ctx = ctx || {};
5892
+ const off = (why) => ({ mode: 'off', why });
5893
+ if (!req || !view) return off('no-read');
5894
+ // Before Save, and while it holds unsaved edits, the stage is the person's own work: Flo stays off it.
5895
+ if (req.filterCheckpointCurrent !== true || ctx.pendingSave) return off('not-saved');
5896
+ if (ctx.contactLost) return off('contact-lost');
5897
+ const progress = req.steelProgress;
5898
+ const raw = progress && progress.status;
5899
+ if (raw === 'cancelled') return off('cancelled');
5900
+ const chat = req.chatConversation || null;
5901
+ const inChat = chat?.executionOwner === 'chat' && typeof chat.chatId === 'string' && !!chat.chatId;
5902
+ const code = req.attention?.code;
5903
+ // Only an asked question or approval counts: `needs-you` alone also means a read nobody linked to a chat,
5904
+ // a stopped run or an answer to read, and the progress view's own `waiting` also covers a stale record.
5905
+ const approval = code === 'approval' || chat?.chatState === 'awaiting-approval';
5906
+ const asked = code === 'ai-question' || approval || ctx.chatAsking === true;
5907
+ const chatWorking = inChat && (chat.chatState === 'starting' || chat.chatState === 'running');
5908
+ // The AI writes `waiting`, then asks or stops. A conversation still running past it has moved on (the person
5909
+ // pressed Save and FloLess continued the read) and the record is stale until the AI next writes it: not a question.
5910
+ const recordWaits = raw === 'waiting' && !chatWorking;
5911
+ if (recordWaits || asked) {
5912
+ const note = recordWaits ? progressText(progress.items.find((item) => item.state === 'waiting')?.note) : null;
5913
+ const question = code === 'ai-question' ? progressText(req.run?.question) : null;
5914
+ // AI Chat's own flag cannot tell a question from an approval, so alone it says neither.
5915
+ const text = note || question || (approval ? 'The AI is waiting for your approval.'
5916
+ : code === 'ai-question' ? 'The AI has asked you a question.' : 'The AI is waiting for you in AI Chat.');
5917
+ return { mode: 'waiting', text, chat: inChat };
5918
+ }
5919
+ if (raw !== 'active') return off('not-active');
5920
+ const looks = (Array.isArray(req.steelLooks) ? req.steelLooks : []).filter(floLookOk);
5921
+ const freshPictures = looks.some((l) => l.ageMs < FLO_FRESH_WORK_MS);
5922
+ // A record the AI has not rewritten for 8 minutes is stale, but pictures it asked for in the last two, or its
5923
+ // conversation still running, prove it is still at work (seen on a real read, #2926: tiles seconds old, sentence
5924
+ // 9 minutes old). Flo keeps going then, and says the sentence is the last one reported, the strip's own words.
5925
+ if (view.state !== 'active') {
5926
+ return freshPictures || chatWorking ? { mode: 'reading', now: view.now, looks, label: 'Last reported:' } : off('not-active');
5927
+ }
5928
+ // Pictures for this very read are proof of work even when the chat calls its turn busy elsewhere, which it
5929
+ // does whenever the person typed into the read's conversation and the read carried on.
5930
+ const working = freshPictures || !inChat || chatWorking;
5931
+ if (!working) return off('idle');
5932
+ return { mode: 'reading', now: view.now, looks };
5933
+ }
5934
+
5935
+ // Keeps the last read and view applyStageGating() painted (`syncFilterFlo.last`), so a chat question opening
5936
+ // between polls re-syncs at once.
5937
+ function syncFilterFlo(req, view) {
5938
+ syncFilterFlo.last = { req, view };
5939
+ const frame = frames.drawings;
5940
+ if (!frame || !frame.dataset.loaded) return;
5941
+ const chatId = req?.chatConversation?.chatId;
5942
+ const chatAsking = !!chatId && document.getElementById('ai-chat-shell')?.dataset.approvalPending === 'true'
5943
+ && window.flolessChat?.currentChatId?.() === chatId;
5944
+ // `read` lets the page drop a picture another read asked for.
5945
+ const state = { ...filterFloState(req, view, { contactLost: revRequestsFailed, chatAsking, pendingSave: drawingFilterPendingSave() }), read: req?.id ?? null };
5946
+ try { frame.contentWindow?.flolessFilterFlo?.(state); }
5947
+ catch (err) {
5948
+ // A frame showing a browser error page is another origin; the next poll tells the reloaded page. Anything
5949
+ // else is a defect in Flo's own code: said once, not on every poll.
5950
+ if (err?.name !== 'SecurityError' && !syncFilterFlo.warned) { syncFilterFlo.warned = true; console.warn('Flo could not show the drawing read', err); }
5951
+ }
5952
+ }
5953
+
5754
5954
  /** Revised drawing reads keep their own card; the strip owns every initial-read handoff it paints. */
5755
5955
  function stageGuidanceOwnsSavedCheckpoint(req) {
5756
5956
  return !!(req && isInitialRevisionRead(req) && (
@@ -5850,6 +6050,20 @@
5850
6050
  markScrollable($stageGuidance);
5851
6051
  }
5852
6052
 
6053
+ /** #2521 row 2c: the "AI's choice" mark beside a Drawing Filter the AI chose, in the band an initial read shows. */
6054
+ function appendStageGuidanceAiFilterPill() {
6055
+ if (!$stageGuidance || $stageGuidance.querySelector('.wsg-ai-pill')) return;
6056
+ const pill = document.createElement('span');
6057
+ pill.className = 'ai-pill wsg-ai-pill';
6058
+ pill.textContent = 'AI’s choice';
6059
+ pill.tabIndex = 0;
6060
+ pill.dataset.tip = FILTER_AI_PILL_TIP;
6061
+ // After the band's words and before its actions, so it reads as part of the sentence it marks.
6062
+ const words = $stageGuidance.querySelector(':scope > span[aria-hidden="true"]');
6063
+ if (words) words.after(pill);
6064
+ else $stageGuidance.append(pill);
6065
+ }
6066
+
5853
6067
  /**
5854
6068
  * The control inside the Drawing Filter that answers its unfinished save (#1781), or null when Save
5855
6069
  * itself is the next action. The sign-off dialog shows Cancel + Approve while it waits, but only
@@ -5980,9 +6194,11 @@
5980
6194
  const title = document.createElement('strong');
5981
6195
  title.textContent = progress.heading;
5982
6196
  summary.append(title);
6197
+ // #2867: the same Done → Now (or Needs you / Blocked) → Heads up → Next order as the expanded
6198
+ // rows below, so collapsing never reshuffles what the person is reading.
5983
6199
  for (const [label, text] of [
5984
- [progress.nowLabel || 'Now', progress.now], ['Heads up', progress.caution],
5985
- ['Done', progress.done], ['Next', progress.next],
6200
+ ['Done', progress.done], [progress.nowLabel || 'Now', progress.now],
6201
+ ['Heads up', progress.caution], ['Next', progress.next],
5986
6202
  ]) {
5987
6203
  if (!text) continue;
5988
6204
  const highlight = document.createElement('b');
@@ -5996,13 +6212,23 @@
5996
6212
  toggle.className = 'wsg-toggle';
5997
6213
  toggle.dataset.commandId = 'shell.workspace-progress-toggle';
5998
6214
  toggle.setAttribute('aria-controls', body.id);
6215
+ // #2867: a chevron, not a word — the shared panel artwork, pointing down while open and right
6216
+ // while folded to one line (the chat cards' convention). The button keeps its spoken name.
6217
+ const svgNs = 'http://www.w3.org/2000/svg';
6218
+ const chevron = document.createElementNS(svgNs, 'svg');
6219
+ chevron.setAttribute('viewBox', '0 0 16 16');
6220
+ chevron.setAttribute('aria-hidden', 'true');
6221
+ chevron.setAttribute('focusable', 'false');
6222
+ const chevronPath = document.createElementNS(svgNs, 'path');
6223
+ chevronPath.setAttribute('d', 'm6 3 5 5-5 5');
6224
+ chevron.appendChild(chevronPath);
6225
+ toggle.appendChild(chevron);
5999
6226
  const apply = () => {
6000
6227
  const collapsed = choices.get(scope) === true;
6001
6228
  $stageGuidance.classList.toggle('is-collapsed', collapsed);
6002
- toggle.textContent = collapsed ? 'Expand' : 'Collapse';
6003
6229
  toggle.setAttribute('aria-label', `${collapsed ? 'Expand' : 'Collapse'} drawing read progress`);
6004
6230
  toggle.setAttribute('aria-expanded', String(!collapsed));
6005
- toggle.setAttribute('data-tip', collapsed ? 'Show full drawing read progress' : 'Keep drawing read progress on one line');
6231
+ toggle.setAttribute('data-tip', collapsed ? 'Expand: show full drawing read progress' : 'Collapse: keep drawing read progress on one line');
6006
6232
  if (live && live.textContent !== compactAnnouncement) live.textContent = compactAnnouncement;
6007
6233
  markScrollable($stageGuidance);
6008
6234
  };
@@ -6086,7 +6312,30 @@
6086
6312
  // Keep steel projects stage-by-stage while the first drawing read is in progress. The later tabs
6087
6313
  // stay visible so the user can see what comes next, but explain their prerequisite instead of
6088
6314
  // opening empty destinations during a potentially long terminal-AI read.
6315
+ /**
6316
+ * #2521 row 2c: the server's verdict on whose Filter Save a read holds (`filterChosenBy`, `quickFilterByAi`,
6317
+ * `filterReceiptProblem` on the request view). The words only follow it; the browser never decides it.
6318
+ */
6319
+ const FILTER_AI_CHOSEN_LEAD = 'The AI chose the Drawing Filter (Quick model)';
6320
+ const FILTER_AI_CHOSEN_NEXT = 'The drawing read carries on with it. You can review it and press Save filter to make it yours.';
6321
+ const FILTER_AI_CHOOSING = 'The AI is choosing the Drawing Filter for this Quick model, as you allowed, and the read carries on once it has. You can still review it and press Save filter yourself.';
6322
+ const FILTER_AI_PILL_TIP = 'The AI chose this Drawing Filter in the Quick model build, and it is recorded as the AI’s, not as your Save. It becomes yours only when you press Save filter.';
6323
+ /**
6324
+ * The AI is still to choose: it may (the server's `quickFilterByAi`), and no Save has been recorded for this read yet.
6325
+ * After any Save a reset sends the read back to the person's Save wording: the AI has moved on and will not choose again.
6326
+ */
6327
+ function filterAiIsChoosing(req) {
6328
+ return req?.quickFilterByAi === true && !req?.filterSaveReceiptId && req?.filterExclusionsAwait !== true;
6329
+ }
6330
+ /** Revision 3a: the AI chose a Filter that leaves lines out, and the person kept that approval (server-derived). */
6331
+ const FILTER_AI_EXCLUSIONS_AWAIT = 'The AI chose the Drawing Filter, and it leaves some lines out of the read. You kept that approval: review what it leaves out and press Save filter in the top-right corner. The read goes on with your Save.';
6332
+ function filterSavedLead(req) {
6333
+ return req?.filterChosenBy === 'ai' ? FILTER_AI_CHOSEN_LEAD : 'The Drawing Filter is saved';
6334
+ }
6335
+
6089
6336
  function savedFilterNextStep(req) {
6337
+ // #2521 row 2c: the AI's choice starts no continuation: the read that made it goes on.
6338
+ if (req?.filterChosenBy === 'ai') return FILTER_AI_CHOSEN_NEXT;
6090
6339
  const continuation = req?.filterSaveContinuation;
6091
6340
  if (continuation?.state === 'queued') return 'FloLess will continue the drawing read in the linked AI Chat when that conversation is ready.';
6092
6341
  if (continuation?.state === 'continuing') return 'FloLess sent the saved filter to the linked AI Chat. Follow that conversation for the drawing read.';
@@ -6100,6 +6349,10 @@
6100
6349
  }
6101
6350
 
6102
6351
  function readyFilterNextStep(req) {
6352
+ // #2521 row 2c: an AI choice that cannot stand says why; one still to come says the AI is choosing.
6353
+ if (req?.filterReceiptProblem?.reason) return req.filterReceiptProblem.reason;
6354
+ if (req?.filterExclusionsAwait === true) return FILTER_AI_EXCLUSIONS_AWAIT;
6355
+ if (filterAiIsChoosing(req)) return FILTER_AI_CHOOSING;
6103
6356
  return readRunsInChat(req)
6104
6357
  ? 'Then press Save filter in the top-right corner. FloLess will continue the drawing read in the linked AI Chat.'
6105
6358
  : 'Then press Save filter in the top-right corner. After Save, return to the terminal AI that prepared it and tell it to continue.';
@@ -6131,7 +6384,7 @@
6131
6384
  // The EARLIER save is on record, but the Filter now holds a newer one nobody has finished (#1781).
6132
6385
  const pendingSave = drawingFilterPendingSave();
6133
6386
  if (pendingSave) return drawingFilterPendingText(pendingSave).replace(' · ', '. ');
6134
- return `The Drawing Filter is saved. ${savedFilterNextStep(revCardReq)}`;
6387
+ return `${filterSavedLead(revCardReq)}. ${savedFilterNextStep(revCardReq)}`;
6135
6388
  }
6136
6389
  if (waitingForInitial && revCardReq?.prepassReady) return `Check steel, member marks, grids, dimensions, and relevant callouts. Ask in AI Chat on the left if you need help. ${readyFilterNextStep(revCardReq)}`;
6137
6390
  if (waitingForInitial && revCardReq?.preparationRetryable) return `Steel Filter preparation was interrupted. Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`;
@@ -6213,6 +6466,7 @@
6213
6466
  const unavailableInitial = initialRead && lastRevState === 'unavailable';
6214
6467
  const ownsProgress = waitingForInitial && stageGuidanceOwnsSavedCheckpoint(revCardReq);
6215
6468
  const liveProgress = ownsProgress ? drawingProgressView(revCardReq, Date.now(), revRequestsFailed) : null;
6469
+ syncFilterFlo(liveProgress ? revCardReq : null, liveProgress);
6216
6470
  if (ownsProgress && revCardReq?.steelProgress && !liveProgress) {
6217
6471
  const revision = Number.isSafeInteger(revCardReq.steelProgress.revision)
6218
6472
  ? String(revCardReq.steelProgress.revision) : `invalid:${String(revCardReq.steelProgress.revision)}`;
@@ -6265,9 +6519,9 @@
6265
6519
  : waitingForInitial && revCardReq?.filterSaveContinuation?.state === 'recovery-needed'
6266
6520
  ? `Drawing Filter needs attention · ${savedFilterNextStep(revCardReq)}`
6267
6521
  : waitingForInitial && revCardReq?.filterCheckpointCurrent
6268
- ? `The Drawing Filter is saved · ${savedFilterNextStep(revCardReq)} Live progress appears here once the read starts.`
6522
+ ? `${filterSavedLead(revCardReq)} · ${savedFilterNextStep(revCardReq)} Live progress appears here once the read starts.`
6269
6523
  : waitingForInitial && revCardReq?.prepassReady
6270
- ? 'Drawing Filter ready for review · ' + (window.FilterGuidance?.scope || 'Check what this steel read may use — not only the steel. Keep the steel plus member labels and sizes, grid references, scale or location dimensions, and relevant detail or section callouts.') + ' Ask in AI Chat on the left if you are unsure. ' + readyFilterNextStep(revCardReq)
6524
+ ? (revCardReq?.filterReceiptProblem || revCardReq?.filterExclusionsAwait === true ? 'Drawing Filter needs your Save · ' : filterAiIsChoosing(revCardReq) ? 'The AI is choosing the Drawing Filter · ' : 'Drawing Filter ready for review · ') + (window.FilterGuidance?.scope || 'Check what this steel read may use — not only the steel. Keep the steel plus member labels and sizes, grid references, scale or location dimensions, and relevant detail or section callouts.') + ' Ask in AI Chat on the left if you are unsure. ' + readyFilterNextStep(revCardReq)
6271
6525
  : waitingForInitial && revCardReq?.preparationRetryable
6272
6526
  ? `Steel Filter preparation was interrupted · Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`
6273
6527
  : waitingForInitial && readWorkingInChat(revCardReq)
@@ -6299,6 +6553,11 @@
6299
6553
  if (waitingForInitial && revCardReq?.prepassReady && !revCardReq?.filterCheckpointCurrent) {
6300
6554
  appendStageGuidanceFilterAction();
6301
6555
  }
6556
+ // #2521 row 2c: the AI's choice is the person's to review, so its band marks it and opens the Filter too.
6557
+ if (waitingForInitial && revCardReq?.filterCheckpointCurrent && revCardReq?.filterChosenBy === 'ai') {
6558
+ appendStageGuidanceAiFilterPill();
6559
+ appendStageGuidanceFilterAction();
6560
+ }
6302
6561
  }
6303
6562
 
6304
6563
  function deferStageUntilLifecycle(s) {
@@ -7829,7 +8088,7 @@
7829
8088
  renderApprovalReview();
7830
8089
  await refreshApprovalState(st.projectId);
7831
8090
  showToast('Discarded the selected working-copy change. Nothing was approved.', 'ok');
7832
- } catch (error) { showToast('We couldn’t discard these changes because FloLess could not save the update. Try again.', 'warn'); }
8091
+ } catch (error) { showFailureToast(error, { action: 'discard these changes' }); }
7833
8092
  }
7834
8093
 
7835
8094
  async function retryApprovalReview() {
@@ -8709,8 +8968,11 @@
8709
8968
  if (knowledgeState) paintKnowledge(knowledgeState);
8710
8969
  return res;
8711
8970
  } catch (err) {
8712
- const said = err && err.body && typeof err.body.error === 'string' ? err.body.error : '';
8713
- showToast(said || 'FloLess could not change your categories just now. Try again.', 'warn');
8971
+ // A category refusal is written for the person (CategoryError); anything else — a busy project, a lost
8972
+ // connection — goes through the shared failure copy (#2868) instead of "try again".
8973
+ const said = err && err.body && /^knowledge-categories-/.test(String(err.body.code || '')) && typeof err.body.error === 'string' ? err.body.error : '';
8974
+ if (said) showToast(said, 'warn');
8975
+ else showFailureToast(err, { action: 'change your categories' });
8714
8976
  // Changed elsewhere since the name box opened: close it, so the person sees the newer names before naming again.
8715
8977
  if (body.expected && err && err.body && err.body.code === 'knowledge-categories-changed') kbCatEdit = null;
8716
8978
  return null;
@@ -10060,9 +10322,11 @@
10060
10322
  kbFocusSourceId = added.sourceId;
10061
10323
  showToast(`Added “${added.filename}”, but couldn’t remove “${old.filename}”. Remove it from the list.`, 'warn');
10062
10324
  } else {
10063
- showToast(err && err.body && err.body.code === 'project-changed'
10064
- ? 'This project was replaced while the file was being read, so nothing changed.'
10065
- : 'Couldn’t replace the file. The original is still there. Check your connection, then try again.', 'warn');
10325
+ // #2868: the original is only removed after the new file is in, so here it is always still there. Whether the new
10326
+ // file went in is known for a refusal (nothing is stored) and not for a lost connection or an unknown failure.
10327
+ if (err && err.body && err.body.code === 'project-changed') showToast('This project was replaced while the file was being read, so nothing changed.', 'warn');
10328
+ else showFailureToast(err, { action: `replace “${old.filename}”`, nothingDone: `Nothing changed; “${old.filename}” is still there.`,
10329
+ retry: 'Try replacing it again', unsure: `“${old.filename}” is still there. FloLess can’t tell whether the new file was added, so check the references list first.` });
10066
10330
  }
10067
10331
  }
10068
10332
  if (current === proj) renderKnowledge();
@@ -10969,11 +11233,19 @@
10969
11233
  }
10970
11234
  track('kb_sources_added', { app: proj.app, n });
10971
11235
  } catch (err) {
10972
- showToast(err && err.body && err.body.code === 'project-changed'
10973
- ? 'This project was replaced while the files were being read, so nothing was added. Choose the files again.'
10974
- // #2491: a file FloLess cannot take (an old .doc, an unsupported type) says why, in the server's plain words.
10975
- : err && err.body && err.body.reason ? `Nothing was added. ${err.body.reason}`
10976
- : 'Couldn’t add these references. Check the files and try again.', 'warn');
11236
+ if (err && err.body && err.body.code === 'project-changed') {
11237
+ showToast('This project was replaced while the files were being read, so nothing was added. Choose the files again.', 'warn');
11238
+ } else {
11239
+ // #2868: the server's facts decide the sentence. A busy project (drawing preparation holds the same project lock)
11240
+ // says what it is busy with and to add the files when it finishes, never that the files are wrong; a file FloLess
11241
+ // cannot take (#2491) gives its reason. "Nothing was added" is proven for the refusals: the route checks the
11242
+ // batch and takes the project lock before it stores anything, and a busy lock never runs the store. A lost
11243
+ // connection or an unknown failure does not claim it.
11244
+ const plural = files.length === 1 ? 'the file' : 'the files';
11245
+ showFailureToast(err, { action: `add ${files.length === 1 ? 'this reference' : 'these references'}`,
11246
+ nothingDone: 'Nothing was added.', retry: `Try adding ${plural} again`,
11247
+ unsure: `FloLess can’t tell whether ${plural === 'the file' ? 'it was' : 'they were'} added. Check the references list before adding ${plural === 'the file' ? 'it' : 'them'} again.` });
11248
+ }
10977
11249
  }
10978
11250
  if (current === proj) renderKnowledge();
10979
11251
  }
@@ -11039,7 +11311,7 @@
11039
11311
  const proj = current;
11040
11312
  if (!proj) return;
11041
11313
  try { await api(kbUrl(proj.id, `/sources/${encodeURIComponent(sourceId)}`), { method: 'PATCH', body: JSON.stringify({ useAsKb: next }) }); }
11042
- catch { showToast('Couldn’t update this reference. Try again.', 'warn'); }
11314
+ catch (err) { showFailureToast(err, { action: 'update this reference' }); }
11043
11315
  if (current === proj) renderKnowledge(); // re-render reconciles the optimistic flip either way
11044
11316
  }
11045
11317
 
@@ -11050,7 +11322,7 @@
11050
11322
  try {
11051
11323
  await api(kbUrl(proj.id, `/sources/${encodeURIComponent(sourceId)}`), { method: 'DELETE' });
11052
11324
  showToast(okMsg || 'Reference removed', 'ok');
11053
- } catch { showToast('Couldn’t remove this reference. Try again.', 'warn'); }
11325
+ } catch (err) { showFailureToast(err, { action: 'remove this reference', nothingDone: 'Nothing was removed.', retry: 'Try removing it again' }); }
11054
11326
  if (current === proj) renderKnowledge();
11055
11327
  }
11056
11328
 
@@ -14678,7 +14950,7 @@
14678
14950
  (res.readiness && res.readiness.message) || 'the agent did not become usable.'}`,
14679
14951
  res.readiness && res.readiness.ok ? 'ok' : 'warn');
14680
14952
  } catch (err) {
14681
- showToast('We couldn’t finish that because FloLess could not save the change. Try again.', 'warn');
14953
+ showFailureToast(err, { action: 'install the Blender agent' });
14682
14954
  // Leaving `checking` in place would strand the card disabled as "Checking…" with no
14683
14955
  // recovery button until the tab is reopened — a failed install that hides its own retry.
14684
14956
  renderReadinessState = {
@@ -15308,8 +15580,15 @@
15308
15580
  if (req.prepassReady && req.filterCheckpointCurrent) {
15309
15581
  const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
15310
15582
  const txt = revEl('span', 'wrc-text');
15311
- txt.appendChild(revEl('b', null, 'Drawing Filter saved.'));
15583
+ txt.appendChild(revEl('b', null, req.filterChosenBy === 'ai' ? 'Drawing Filter chosen by the AI.' : 'Drawing Filter saved.'));
15312
15584
  txt.appendChild(document.createTextNode(` ${savedFilterNextStep(req)}`));
15585
+ // #2521 row 2c: who chose it, at a glance; the words above say what to do about it.
15586
+ if (req.filterChosenBy === 'ai') {
15587
+ const pill = revEl('span', 'ai-pill wrc-ai-pill', 'AI’s choice');
15588
+ pill.dataset.tip = FILTER_AI_PILL_TIP;
15589
+ pill.tabIndex = 0;
15590
+ return [dot, txt, pill];
15591
+ }
15313
15592
  return [dot, txt];
15314
15593
  }
15315
15594
  // Defensive fallback for a strip that could not paint; ordinary initial reads put this action in
@@ -15519,7 +15798,7 @@
15519
15798
  try { await api(`/api/requests/${encodeURIComponent(req.id)}`, { method: 'DELETE' }); }
15520
15799
  catch (error) {
15521
15800
  if (!ownsDismiss()) return;
15522
- showToast('We couldn’t dismiss this drawing because FloLess could not save the change. Try again.', 'warn');
15801
+ showFailureToast(error, { action: 'dismiss this drawing' });
15523
15802
  if (bridge.loadRequests) await bridge.loadRequests().catch(() => {});
15524
15803
  await renderRevisionCard();
15525
15804
  return;
@@ -15694,6 +15973,7 @@
15694
15973
  syncDrawingRevisionRequest(
15695
15974
  pending?.prepassReady ? pending.id : '',
15696
15975
  pending?.prepassReady && pending.filterCheckpointCurrent ? pending.filterSavedEtag : '',
15976
+ pending?.prepassReady && pending.filterCheckpointCurrent && pending.filterChosenBy === 'ai' ? 'ai' : '',
15697
15977
  );
15698
15978
  if (currentStep !== 'drawings') { $revisionCard.hidden = true; applyStageGating(); return; } // card is Drawing Filter-scoped
15699
15979
  // A REVIEW IS OPEN — leave the card alone. Repainting it would replace the button focus returns to,
@@ -15714,6 +15994,8 @@
15714
15994
  // (`applyStageGating()` still runs on the short-circuit path, which is why only one of the two
15715
15995
  // surfaces went stale — and why the contradiction was visible at all.)
15716
15996
  + `:${revCardReq?.chatConversation?.executionOwner || ''}:${revCardReq?.chatConversation?.chatState || ''}`
15997
+ // #2521 row 2c: whose Filter Save it is changes the words too, and none of the fields above implies it.
15998
+ + `:${pending?.filterChosenBy || ''}:${filterAiIsChoosing(pending)}:${pending?.filterExclusionsAwait === true}:${pending?.filterReceiptProblem?.reason || ''}`
15717
15999
  + (staged ? `:${staged.baseVersion}:${staged.headVersion}:${staged.stageId || ''}:${staged.canDiscardRevision === true}:${staged.discardState || ''}:${staged.discardWhy || ''}:${staged.canClear === true}:${staged.clearWhy || ''}:${unavailableRevisionReviewStages.has(staged.stageId)}` : '');
15718
16000
  // The key below exists to preserve focus in the card across the three-second poll. It says
15719
16001
  // nothing about the strip, whose progress record advances on its own revision, so the strip is
@@ -15738,11 +16020,13 @@
15738
16020
  }
15739
16021
 
15740
16022
  /** Keep the request checkpoint in the already-open Drawing Filter without navigating away edits. */
15741
- function syncDrawingRevisionRequest(targetRequest, targetSavedEtag = '') {
16023
+ function syncDrawingRevisionRequest(targetRequest, targetSavedEtag = '', targetChosenBy = '') {
15742
16024
  const frame = frames.drawings;
15743
16025
  if (!frame?.dataset.want) return;
15744
16026
  const requestId = String(targetRequest || '');
15745
16027
  const savedEtag = requestId ? String(targetSavedEtag || '') : '';
16028
+ // #2521 row 2c: whose save the checkpoint is, so the Filter can offer to save the AI's choice as the person's.
16029
+ const chosenBy = savedEtag && targetChosenBy === 'ai' ? 'ai' : '';
15746
16030
  let bridged = false;
15747
16031
  if (frame.dataset.loaded) {
15748
16032
  try {
@@ -15750,7 +16034,7 @@
15750
16034
  if (checkpoint && typeof checkpoint.setRequest === 'function') {
15751
16035
  // `false` means this exact child Save owns a transient E1→empty invalidation. Do not let the
15752
16036
  // same stale poll rewrite dataset.want either, or the next iframe load would replay the gap.
15753
- if (checkpoint.setRequest(requestId, savedEtag) === false) return false;
16037
+ if (checkpoint.setRequest(requestId, savedEtag, chosenBy) === false) return false;
15754
16038
  bridged = true;
15755
16039
  }
15756
16040
  } catch { /* not ready or not same-origin yet — reconcile through the target URL below */ }
@@ -15760,12 +16044,15 @@
15760
16044
  else wanted.searchParams.delete('revisionRequest');
15761
16045
  if (savedEtag) wanted.searchParams.set('revisionFilterSavedEtag', savedEtag);
15762
16046
  else wanted.searchParams.delete('revisionFilterSavedEtag');
16047
+ if (chosenBy) wanted.searchParams.set('revisionFilterChosenBy', chosenBy);
16048
+ else wanted.searchParams.delete('revisionFilterChosenBy');
15763
16049
  frame.dataset.want = wanted.pathname + wanted.search;
15764
16050
  if (!frame.dataset.loaded || bridged) return true;
15765
16051
  try {
15766
16052
  const shown = new URL(frame.contentWindow.location.href);
15767
16053
  if ((shown.searchParams.get('revisionRequest') || '') === requestId
15768
- && (shown.searchParams.get('revisionFilterSavedEtag') || '') === savedEtag) return true;
16054
+ && (shown.searchParams.get('revisionFilterSavedEtag') || '') === savedEtag
16055
+ && (shown.searchParams.get('revisionFilterChosenBy') || '') === chosenBy) return true;
15769
16056
  } catch { /* not ready or not same-origin yet — navigate to the authoritative target below */ }
15770
16057
  frame.src = frame.dataset.want;
15771
16058
  return true;
@@ -15815,6 +16102,20 @@
15815
16102
  // the Drawing Filter tab and the Model tab's tooltip all read that state, so repaint them now rather
15816
16103
  // than at the next three-second poll — or never, on a step that has no poll running.
15817
16104
  window.addEventListener('floless:filter-ai-changed', () => { if (current) applyStageGating(); });
16105
+ // #2926: a question or approval opening in AI Chat between polls moves the Drawing Filter's Flo to its waiting corner now.
16106
+ function resyncFilterFlo() {
16107
+ const last = syncFilterFlo.last;
16108
+ // Only the open project's read: between a project switch and its first poll, `last` is the project left.
16109
+ if (current && last?.req?.project === current.id) syncFilterFlo(last.req, last.view);
16110
+ }
16111
+ document.addEventListener('floless:chat-indicator', resyncFilterFlo);
16112
+ // #2926: Flo's "Answer in AI Chat" opens the read's own conversation, where the question is.
16113
+ window.addEventListener('floless:filter-flo-answer', () => {
16114
+ const chatId = syncFilterFlo.last?.req?.chatConversation?.chatId;
16115
+ if (!chatId) return;
16116
+ Promise.resolve().then(() => window.flolessChat.openConversation(chatId))
16117
+ .catch((err) => showFailureToast(err, { action: 'open the question in AI Chat' }));
16118
+ });
15818
16119
  frames.drawings.addEventListener('load', () => {
15819
16120
  requestAnimationFrame(() => {
15820
16121
  reconcileDrawingRevisionRequestAfterLoad();
@@ -17298,7 +17599,7 @@
17298
17599
  }
17299
17600
  return;
17300
17601
  }
17301
- showToast('We couldn’t apply that change because FloLess could not save it. Try again.', 'warn');
17602
+ showFailureToast(err, { action: 'apply that change' });
17302
17603
  closeRevReview(); // repaints the card itself
17303
17604
  return;
17304
17605
  }
@@ -18869,7 +19170,7 @@
18869
19170
  showToast(replacing ? 'Thumbnail replaced ✓' : 'Thumbnail added ✓', 'ok');
18870
19171
  track('workspace_project_thumbnail_set', { app: project.app, replaced: replacing });
18871
19172
  } catch (err) {
18872
- showToast('We couldn’t save that thumbnail because FloLess could not save the change. Try again.', 'warn');
19173
+ showFailureToast(err, { action: 'save that thumbnail' });
18873
19174
  } finally { projActionBusy = false; }
18874
19175
  loadProjects(); // background reconcile, mirroring rename/duplicate/archive
18875
19176
  }
@@ -19478,9 +19779,13 @@
19478
19779
  const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
19479
19780
  // #2471: or one member an AI Chat answer cited, with the project identity it was cited in (checked at handover).
19480
19781
  const member = !!target && !validId(target.jointId) && validId(target.memberId);
19481
- const thing = member ? 'member' : 'connection';
19482
- const again = member ? 'Show in the model' : 'Open in the model';
19483
- if (!target || !validId(target.projectId) || !(validId(target.jointId) || member)) throw connectionError(`That ${thing} could not be opened. Open its project from Workspaces.`);
19782
+ // #2874: or one RFI a chat message mentioned, shown on the project's RFIs step (in the editor, or the shell's own pane).
19783
+ const rfi = !!target && !validId(target.jointId) && !member && validId(target.rfiId) && /^RFI-\d{3,16}$/.test(target.rfiId);
19784
+ // Sentences say "the member was not shown", but "RFI-007 was not shown".
19785
+ const thing = member ? 'the member' : rfi ? target.rfiId : 'the connection';
19786
+ const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : 'Open in the model';
19787
+ const step = rfi ? 'rfis' : 'model';
19788
+ if (!target || !validId(target.projectId) || !(validId(target.jointId) || member || rfi)) throw connectionError(`That ${member ? 'member' : rfi ? 'RFI' : 'connection'} could not be opened. Open its project from Workspaces.`);
19484
19789
  const mine = { id: `connection-${++connectionRequestSeq}`, page: null };
19485
19790
  withdrawConnectionRequest(connectionRequest);
19486
19791
  connectionRequest = mine;
@@ -19488,8 +19793,8 @@
19488
19793
  // Once this call has ended, for any reason, a project change it started gives way before it lands.
19489
19794
  let ended = false;
19490
19795
  const stillWanted = () => !ended && !superseded();
19491
- const stayedOutside = () => connectionError(`You stayed where you were, so the ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
19492
- const leftWorkspaces = () => connectionError(`You left Workspaces, so the ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
19796
+ const stayedOutside = () => connectionError(`You stayed where you were, so ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
19797
+ const leftWorkspaces = () => connectionError(`You left Workspaces, so ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
19493
19798
  const pause = () => new Promise((resolve) => setTimeout(resolve, 100));
19494
19799
  /**
19495
19800
  * Wait for a step of getting there, watched: a later click ends it at once. `bounded` adds the deadline,
@@ -19506,12 +19811,12 @@
19506
19811
  await Promise.race([finished, pause()]);
19507
19812
  if (done) { if (done.error) throw done.error; return done.value; }
19508
19813
  if (superseded()) return { superseded: true };
19509
- if (Date.now() >= bound) throw connectionError(`The project did not open in time, so the ${thing} was not shown. Open it from Workspaces, then press ${again} again.`);
19814
+ if (Date.now() >= bound) throw connectionError(`The project did not open in time, so ${thing} was not shown. Open it from Workspaces, then press ${again} again.`);
19510
19815
  }
19511
19816
  };
19512
19817
  // A project removed and made again under the same id is not the one the answer cited.
19513
19818
  const citedElsewhere = () => validId(target.projectUuid) && String(current?.uuid || '').toLowerCase() !== target.projectUuid.toLowerCase();
19514
- const citedGone = () => connectionError(`This project is no longer the one the answer cited, so the ${thing} was not shown.`);
19819
+ const citedGone = () => connectionError(`This project is no longer the one ${rfi ? 'the message mentioned' : 'the answer cited'}, so ${thing} was not shown.`);
19515
19820
  let until = Infinity;
19516
19821
  // #2605: the document the model frame held before this call opened the project. Left for the Workspaces list,
19517
19822
  // a project's editor page stays in the hidden frame, and openProject's reset of it lands only later: until
@@ -19521,13 +19826,16 @@
19521
19826
  const interrupted = () => {
19522
19827
  if (superseded()) return { superseded: true };
19523
19828
  if (mode !== 'workspaces') throw leftWorkspaces();
19524
- if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so the ${thing} was not shown.`);
19829
+ if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
19525
19830
  // The project's stages kept the Model step locked, or the person went to another step: the step's
19526
19831
  // own message says why, and there is nothing to wait for.
19527
- if (currentStep !== 'model' && !(pendingPresenceStep && pendingPresenceStep.step === 'model')) {
19528
- throw connectionError(`The Model step is not open, so the ${thing} was not shown. Open the Model step, then press ${again} again.`);
19832
+ // An RFI's step is RFIs, which in a steel project shows this same editor frame (and the editor may switch to it).
19833
+ const steps = rfi ? ['model', 'rfis'] : ['model'];
19834
+ if (!steps.includes(currentStep) && !(pendingPresenceStep && steps.includes(pendingPresenceStep.step))) {
19835
+ throw connectionError(rfi ? `The RFIs step is not open, so ${thing} was not shown. Open the RFIs step, then press ${again} again.`
19836
+ : `The Model step is not open, so ${thing} was not shown. Open the Model step, then press ${again} again.`);
19529
19837
  }
19530
- if (Date.now() >= until) throw connectionError(`The model did not open in time, so the ${thing} was not shown. Open the Model step, then press ${again} again.`);
19838
+ if (Date.now() >= until) throw connectionError(`The model did not open in time, so ${thing} was not shown. Open the Model step, then press ${again} again.`);
19531
19839
  return null;
19532
19840
  };
19533
19841
  try {
@@ -19536,16 +19844,27 @@
19536
19844
  if (mode !== 'workspaces') throw stayedOutside();
19537
19845
  if (current?.id !== target.projectId) {
19538
19846
  try { pageLeftBehind = frames.model.contentWindow?.document ?? null; } catch { pageLeftBehind = null; }
19539
- const opened = await navigating(openProject(target.projectId, 'model', { stillWanted }), true);
19847
+ const opened = await navigating(openProject(target.projectId, step, { stillWanted }), true);
19540
19848
  if (opened?.superseded || superseded()) return { superseded: true };
19541
19849
  // openProject answers "stayed" for several causes (the person chose to stay, the project's folder is
19542
19850
  // not available and its dialog is open, another navigation took over): say only what is certain.
19543
- if (opened === STAYED_IN_PROJECT) throw connectionError(`That project did not open, so the ${thing} was not shown. Open it from Workspaces to see why, then press ${again} again.`);
19851
+ if (opened === STAYED_IN_PROJECT) throw connectionError(`That project did not open, so ${thing} was not shown. Open it from Workspaces to see why, then press ${again} again.`);
19544
19852
  if (current?.id !== target.projectId) throw connectionError('That project could not be opened. Open it from Workspaces.');
19545
- } else if (currentStep !== 'model') {
19546
- setStep('model');
19853
+ } else if (currentStep !== step) {
19854
+ setStep(step);
19855
+ }
19856
+ // #2874: a General project's RFIs are the shell's own pane (project-rfis.js), which shows the RFI itself.
19857
+ if (rfi && !wsApp()?.rfisInEditor) {
19858
+ if (citedElsewhere()) throw citedGone();
19859
+ if (typeof globalThis.flolessProjectRfis?.focus !== 'function') throw connectionError(`FloLess could not show ${thing} here. Open the RFIs step and find it there.`);
19860
+ const outcome = await navigating(Promise.resolve(globalThis.flolessProjectRfis.focus(target.projectId, target.rfiId)), true);
19861
+ if (outcome?.superseded || superseded()) return { superseded: true };
19862
+ if (mode !== 'workspaces' || current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
19863
+ // The list may finish loading after the person has moved on: what it showed is out of sight, so say that.
19864
+ if (currentStep !== 'rfis') throw connectionError(`You moved to another step, so ${thing} was not shown. Press ${again} again to see it.`);
19865
+ return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: `FloLess could not show ${thing}. Open the RFIs step and find it there.` };
19547
19866
  }
19548
- if (!frames.model.dataset.want) throw connectionError(`This project has no model editor to show the ${thing} in.`);
19867
+ if (!frames.model.dataset.want) throw connectionError(`This project has no model editor to show ${thing} in.`);
19549
19868
  // The editor's deadline starts once the person is in the project.
19550
19869
  until = Date.now() + CONNECTION_FRAME_WAIT_MS;
19551
19870
  let answer = null, settled = null, page = null, doc = null;
@@ -19558,8 +19877,8 @@
19558
19877
  if (superseded()) return { superseded: true };
19559
19878
  // The Model step may have been left after the selection, but not Workspaces: hidden, it shows nothing.
19560
19879
  if (mode !== 'workspaces') throw leftWorkspaces();
19561
- if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so the ${thing} was not shown.`);
19562
- if (frames.model.contentWindow !== page || page.document !== doc) throw connectionError(`The model reloaded, so the ${thing} was not shown. Press ${again} again.`);
19880
+ if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
19881
+ if (frames.model.contentWindow !== page || page.document !== doc) throw connectionError(`The model reloaded, so ${thing} was not shown. Press ${again} again.`);
19563
19882
  const outcome = settled.outcome;
19564
19883
  return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: notTaken };
19565
19884
  }
@@ -19573,7 +19892,7 @@
19573
19892
  if (citedElsewhere()) throw citedGone();
19574
19893
  // The frame's window survives a reload; its DOCUMENT does not. That is what tells a reload apart.
19575
19894
  page = child; doc = child.document;
19576
- answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
19895
+ answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : rfi ? { rfiId: target.rfiId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
19577
19896
  // #2450: the readiness card's "Raise an RFI" also opens the editor's review dialog for it.
19578
19897
  ...(target.raiseRfi === true ? { raiseRfi: true } : {}), ...(validId(target.checkId) ? { checkId: target.checkId } : {}) });
19579
19898
  if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };
@@ -19584,7 +19903,7 @@
19584
19903
  });
19585
19904
  }
19586
19905
  } else if (child !== page || child.document !== doc) {
19587
- throw connectionError(`The model reloaded, so the ${thing} was not shown. Press ${again} again.`);
19906
+ throw connectionError(`The model reloaded, so ${thing} was not shown. Press ${again} again.`);
19588
19907
  }
19589
19908
  await pause();
19590
19909
  }
@@ -19927,8 +20246,11 @@
19927
20246
  syncWorkspaceReporter, openChatOwner, openPagesHome, folderDecisionCompleted,
19928
20247
  // Project access (project-access.js loads after this file): the project open now, or null.
19929
20248
  currentProject: () => ($app.classList.contains('mode-workspaces') && current ? current : null),
19930
- // #2470 R6.2: whether the open project's kind has this step (a General project has Workflows; the others not yet).
20249
+ // #2470 R6.2: whether the open project's kind has this step. Every kind has Workflows since R6.2b; Project access still asks,
20250
+ // so a kind without the step would get its owned workflows listed in full there.
19931
20251
  projectHasStep: (key) => Boolean(current && wsDescOf(current)?.steps?.some((st) => st.key === key)),
20252
+ // #2470 R6.2b: a project kind's name as the person sees it ("Trace", "Drawing Checker"), for labels outside this file.
20253
+ kindLabelOf: (project) => (project && wsDescOf(project)?.displayName) || null,
19932
20254
  };
19933
20255
  applyMode(); // restore persisted mode immediately (matches panels.js applyView timing)
19934
20256
  })();