@floless/app 0.166.0 → 0.167.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.
@@ -254,6 +254,29 @@
254
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
255
  });
256
256
 
257
+ def('filter.flo-minimize', {
258
+ label: 'Minimize Flo',
259
+ actsOn: 'Tucks Flo into the Show Flo button',
260
+ group: 'On the Drawing Filter canvas',
261
+ persistence: 'local',
262
+ interaction: 'instant',
263
+ risk: [],
264
+ guidance: 'on-demand',
265
+ why: 'The button in the corner of Flo’s bubble does what turning Show Flo off does: Flo shrinks into the Show Flo button at the bottom left and stays off on this computer until you press Show Flo again. If the AI is waiting for your answer meanwhile, Show Flo shows a dot. It changes nothing in the filter.',
266
+ });
267
+
268
+ def('filter.flo-move', {
269
+ label: 'Move Flo',
270
+ actsOn: 'Moves Flo to another place on the drawing',
271
+ group: 'On the Drawing Filter canvas',
272
+ key: 'Also: Arrow keys move it · hold Shift for a larger step · Enter, Escape or double-click lets it follow again',
273
+ persistence: 'none',
274
+ interaction: 'gesture',
275
+ risk: [],
276
+ guidance: 'on-demand',
277
+ why: 'Drag Flo, or focus it and use the arrow keys, to move it off something you want to see. It stays where you put it while the outline keeps following the reading; double-click it, press Escape, or turn Flo off and on to let it follow again. It changes nothing in the filter.',
278
+ });
279
+
257
280
  def('filter.flo-show-sheet', {
258
281
  label: 'Show the sheet Flo is reading',
259
282
  actsOn: 'Opens the sheet the AI is reading now',
@@ -921,7 +921,8 @@
921
921
 
922
922
  def('shell.restore-workflow', {
923
923
  label: 'Restore the official workflow',
924
- actsOn: 'Restores the reviewed official workflow; a source repair still needs your Compile approval',
924
+ actsOn: 'Puts FloLess’s version of {instance} back and makes it ready to run; a backup is saved first and Undo puts your version back',
925
+ anyInstance: 'the workflow',
925
926
  group: 'In the header',
926
927
  persistence: 'working',
927
928
  interaction: 'instant',
@@ -972,7 +973,7 @@
972
973
 
973
974
  def('shell.workflow-update', {
974
975
  label: 'Workflow update',
975
- actsOn: 'Reviews the bundled update or compatibility repair for {instance} without approving the model',
976
+ actsOn: 'Shows what is new in {instance} and updates it in one click',
976
977
  group: 'In the FloLess dialogs',
977
978
  persistence: 'none',
978
979
  interaction: 'dialog',
@@ -982,13 +983,59 @@
982
983
 
983
984
  def('shell.workflow-update-apply', {
984
985
  label: 'Update the workflow',
985
- actsOn: 'Applies the reviewed update or compatibility repair, or prepares an unsent AI Chat review for a customized workflow; Steel Model changes never approve your model',
986
+ actsOn: 'Updates {instance} to FloLess’s newer version and makes it ready to run; your saved data is kept',
986
987
  group: 'In the workflow picker',
987
988
  persistence: 'working',
988
989
  interaction: 'instant',
990
+ risk: ['destructive'],
991
+ guidance: 'on-demand',
992
+ why: 'A backup is saved first and Undo puts it back. If you changed the workflow yourself, the update replaces those changes (they stay in the backup). A Steel Model then needs its model approved once in Workspaces.',
993
+ });
994
+
995
+ def('shell.workflow-update-all', {
996
+ label: 'Update all workflows',
997
+ actsOn: 'Updates every workflow you have not changed yourself, one after another',
998
+ group: 'In the FloLess dialogs',
999
+ persistence: 'working',
1000
+ interaction: 'instant',
1001
+ risk: ['destructive'],
1002
+ guidance: 'on-demand',
1003
+ why: 'Workflows you changed are left for you to decide one by one, because updating replaces your changes.',
1004
+ });
1005
+
1006
+ def('shell.workflow-update-undo', {
1007
+ label: 'Undo the update',
1008
+ actsOn: 'Puts {instance} back the way it was before its last update or restore',
1009
+ anyInstance: 'the workflow',
1010
+ group: 'In the FloLess dialogs',
1011
+ persistence: 'working',
1012
+ interaction: 'instant',
1013
+ risk: ['destructive'],
1014
+ guidance: 'on-demand',
1015
+ why: 'Uses the backup saved just before the update, including the approval it had then.',
1016
+ });
1017
+
1018
+ def('shell.workflow-update-keep-mine', {
1019
+ label: 'Keep my changes (AI)',
1020
+ actsOn: 'Prepares an AI Chat request to bring your own changes in {instance} into FloLess’s newer version',
1021
+ group: 'In the FloLess dialogs',
1022
+ persistence: 'none',
1023
+ interaction: 'dialog',
989
1024
  risk: [],
990
1025
  guidance: 'on-demand',
991
- why: 'A backup is saved first. A narrow compatibility repair preserves your other source bytes and version. Customized workflows need individual review before a full update.',
1026
+ why: 'Nothing changes until you send the request in AI Chat, and the AI never approves the result for you.',
1027
+ });
1028
+
1029
+ def('shell.workflow-update-undo-anyway', {
1030
+ label: 'Undo anyway',
1031
+ actsOn: 'Puts {instance} back the way it was before its last update or restore, replacing the changes made since',
1032
+ anyInstance: 'the workflow',
1033
+ group: 'In the FloLess dialogs',
1034
+ persistence: 'working',
1035
+ interaction: 'instant',
1036
+ risk: ['destructive'],
1037
+ guidance: 'on-demand',
1038
+ why: 'The changes made since the update are backed up first, with their own Undo, so nothing is lost.',
992
1039
  });
993
1040
 
994
1041
  def('shell.project-select', {
@@ -2152,6 +2199,38 @@
2152
2199
  why: 'The drawing read is paused until you review the selected lines, press Save filter, and answer any confirmation it asks.',
2153
2200
  });
2154
2201
 
2202
+ def('shell.read-complete-open-model', {
2203
+ label: 'Open model',
2204
+ actsOn: 'Opens the Model tab of this project, where the model the drawing read just built is shown',
2205
+ group: 'In the project workspace',
2206
+ persistence: 'none',
2207
+ interaction: 'instant',
2208
+ risk: [],
2209
+ guidance: 'on-demand',
2210
+ why: 'The drawing read has finished and saved a new version on History. The model is ready to look at; it has not been checked or approved.',
2211
+ });
2212
+
2213
+ def('shell.read-complete-new-chat', {
2214
+ label: 'Start new chat',
2215
+ actsOn: 'Opens a fresh AI Chat conversation in this project; the drawing-read conversation stays in your chat history',
2216
+ group: 'In the project workspace',
2217
+ persistence: 'none',
2218
+ interaction: 'instant',
2219
+ risk: [],
2220
+ guidance: 'on-demand',
2221
+ why: 'The drawing-read chat holds a lot of context, so continuing in it may use more tokens and cost more. A new chat still works from this project’s saved model; it does not copy the earlier conversation.',
2222
+ });
2223
+
2224
+ def('shell.read-complete-dismiss', {
2225
+ label: 'Dismiss the drawing-read notice',
2226
+ actsOn: 'Closes the “Your model is ready to view” notice for this version. The model and History are unchanged',
2227
+ group: 'In the project workspace',
2228
+ persistence: 'local',
2229
+ interaction: 'instant',
2230
+ risk: [],
2231
+ guidance: 'on-demand',
2232
+ });
2233
+
2155
2234
  def('shell.revision-request-copy', {
2156
2235
  label: 'Copy drawing-read request',
2157
2236
  actsOn: 'Copies the waiting drawing-read instruction for your terminal AI',
@@ -3679,12 +3758,24 @@
3679
3758
  group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
3680
3759
  why: 'FloLess shows only what it can still prove: a sheet whose stored picture changed is shown from its source drawing and says so; a page that changed is not shown as the cited page.',
3681
3760
  });
3761
+ // #3002: a cited Knowledge reference file that was replaced after the answer: the file as it is now, labelled as such.
3762
+ def('shell.chat-cite-open-current', {
3763
+ label: 'Show a cited file as it is now', actsOn: 'Shows the Knowledge reference file as it is now, under a line saying it is not the version the answer cited; nothing changes',
3764
+ group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
3765
+ why: 'FloLess never shows a replaced file as the one the answer cited; the current file is offered only with that said above it.',
3766
+ });
3767
+ // #3001: FloLess's dimension check marks numbers that look like dimensions with no citation or assumption marker.
3768
+ def('shell.chat-uncited-dimensions', {
3769
+ label: 'Go to the next number with no citation or assumption marker', actsOn: 'Moves to the next number in this answer that has no citation or assumption marker; nothing changes',
3770
+ group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
3771
+ why: 'FloLess looks only at numbers that look like dimensions (mm, feet and inches, fractions, steel sections). A marked number has no citation or assumption marker in its sentence; an unmarked one is not proof that a source supports it.',
3772
+ });
3682
3773
  def('shell.chat-cite-ask', {
3683
3774
  label: 'Ask for a missing source', actsOn: 'Puts a question in the message box asking where a claim without a source comes from; nothing is sent until you press Send',
3684
3775
  group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
3685
3776
  });
3686
3777
  def('shell.chat-cite-assume', {
3687
- label: 'Record a claim as an assumption', actsOn: 'Saves, with your name and the date, your decision to go on with a claim that has no source; the claim is labelled Assumption and the AI receives it with your next message. Nothing runs, and nothing is typed or sent now',
3778
+ label: 'Record a claim as an assumption', actsOn: 'Saves, with your name and the date, your decision to go on with a claim that has no source, or whose cited source FloLess found gone ({instance}); the claim is labelled Assumption and the AI receives it with your next message. Nothing runs, and nothing is typed or sent now', anyInstance: 'a claim in an answer',
3688
3779
  group: 'In AI Chat', persistence: 'working', interaction: 'instant', risk: [], guidance: 'on-demand',
3689
3780
  why: 'Going on is always your choice, and only you can make it: the record stays with the answer after a reload, and the claim still shows no source, because an assumption is not one.',
3690
3781
  });
@@ -3696,7 +3787,7 @@
3696
3787
  });
3697
3788
  // #2643: the person names the source of a claim the AI gave none for: a sheet or model member FloLess finds in the project.
3698
3789
  def('shell.chat-cite-choose', {
3699
- label: 'Choose the source of a claim', actsOn: 'Opens a list of the project’s sheets, model members and Knowledge pages, and the files sent in this conversation, to pick the one a claim with no source comes from; nothing is typed or sent',
3790
+ label: 'Choose the source of a claim', actsOn: 'Opens a list of the project’s sheets, model members and Knowledge pages, and the files sent in this conversation, to pick the one a claim with no source, or whose cited source FloLess found gone ({instance}), comes from; nothing is typed or sent', anyInstance: 'a claim in an answer',
3700
3791
  group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
3701
3792
  why: 'Only you can choose a source. It is recorded as chosen by you, with the date, and never as read by the AI: nothing checks that the source supports the claim.',
3702
3793
  });
@@ -4051,7 +4142,7 @@
4051
4142
  label: 'Open the screen for a step only you can do', actsOn: 'Opens the screen for “{instance}”, which you do yourself; nothing runs from the card',
4052
4143
  anyInstance: 'the step on the card',
4053
4144
  group: 'In AI Chat', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
4054
- why: 'Approving, sealing or issuing is always a person’s decision, so the AI can only point you to where it is done.',
4145
+ why: 'Approving, sealing or issuing, or letting the AI choose a Quick model’s Drawing Filter, is always a person’s decision, so the AI can only point you to where it is done.',
4055
4146
  });
4056
4147
  def('shell.chat-action-view', {
4057
4148
  label: 'View what a finished action made', actsOn: 'Opens what “{instance}” made, such as a run’s report; nothing runs again',
@@ -4153,7 +4244,7 @@
4153
4244
  label: 'Open the screen for a step only you can do', actsOn: 'Opens the screen for “{instance}”, which you do yourself; nothing runs from here',
4154
4245
  anyInstance: 'the step on the card',
4155
4246
  group: 'In the terminal requests dialog', persistence: 'none', interaction: 'instant', risk: [], guidance: 'on-demand',
4156
- why: 'Approving, sealing or issuing is always a person’s decision, so a terminal can only point you to where it is done.',
4247
+ why: 'Approving, sealing or issuing, or letting the AI choose a Quick model’s Drawing Filter, is always a person’s decision, so a terminal can only point you to where it is done.',
4157
4248
  });
4158
4249
  def('shell.terminal-request-view', {
4159
4250
  label: 'View what a finished request made', actsOn: 'Opens what “{instance}” made, such as a run’s report; nothing runs again',
@@ -4661,6 +4752,16 @@
4661
4752
  guidance: 'on-demand',
4662
4753
  why: 'Each reason is explained once, with the workflows it applies to listed below it. Workflows that need nothing from you start closed.',
4663
4754
  });
4755
+ def('shell.tool-updates-tools', {
4756
+ label: 'Show or hide tool updates',
4757
+ actsOn: 'Opens or closes the tool approvals and cleanup under the workflow updates',
4758
+ group: 'In the FloLess dialogs',
4759
+ persistence: 'none',
4760
+ interaction: 'instant',
4761
+ risk: [],
4762
+ guidance: 'on-demand',
4763
+ why: 'Workflow updates come first because they are one click each. Tool approvals still wait here, and the heading says how many need you.',
4764
+ });
4664
4765
 
4665
4766
  /* ── the ≡ menu's settings ──────────────────────────────────────────────── */
4666
4767
 
@@ -5081,7 +5182,7 @@
5081
5182
 
5082
5183
  def('shell.project-history-search', {
5083
5184
  label: 'Search history',
5084
- actsOn: 'Shows only the events whose words, area or author match what you type. Only the events already shown are searched',
5185
+ actsOn: 'Shows only the events whose words, area, author or details match what you type. Only the events already shown are searched',
5085
5186
  group: HISTORY_STEP,
5086
5187
  persistence: 'none',
5087
5188
  interaction: 'instant',
@@ -5110,6 +5211,29 @@
5110
5211
  guidance: 'on-demand',
5111
5212
  });
5112
5213
 
5214
+ // #2470 R6.5c: an event a watcher reacted to opens to show what changed and what the workflow did.
5215
+ def('shell.project-history-detail', {
5216
+ label: 'Show or hide the details of the event at {instance}',
5217
+ actsOn: 'Opens or closes what a watcher reacted to: what changed, as the source reported it, and how each step of the workflow went',
5218
+ anyInstance: 'one event',
5219
+ group: HISTORY_STEP,
5220
+ persistence: 'none',
5221
+ interaction: 'instant',
5222
+ risk: [],
5223
+ guidance: 'on-demand',
5224
+ });
5225
+
5226
+ def('shell.project-history-open', {
5227
+ label: 'Open workflow',
5228
+ actsOn: 'Opens the workflow that reacted to the event at {instance}; its Execution tab shows the run. Nothing is run',
5229
+ anyInstance: 'one event',
5230
+ group: HISTORY_STEP,
5231
+ persistence: 'none',
5232
+ interaction: 'instant',
5233
+ risk: [],
5234
+ guidance: 'on-demand',
5235
+ });
5236
+
5113
5237
  def('shell.project-history-earlier', {
5114
5238
  label: 'Show earlier',
5115
5239
  actsOn: 'Loads the next hundred older events below the ones shown',
@@ -145,7 +145,7 @@
145
145
  appears only when its logic drifted (re-installs the official version); Customize (fork) is
146
146
  always available for a maintained app. When shown on drift they replace Compile, so a
147
147
  shipped app's logic edit can't be silently approved (form-only). -->
148
- <button data-command-id="shell.restore-workflow" id="restore-btn" type="button" hidden data-tip="Restore the official workflow — undoes any out-of-band edits and re-arms Run">↺ Restore</button>
148
+ <button data-command-id="shell.restore-workflow#the open workflow" data-command-instance-label="the open workflow" id="restore-btn" type="button" hidden data-tip="Put FloLess’s version of this workflow back and make it ready to run. Your changes are kept in a backup, and Undo puts them back.">↺ Restore</button>
149
149
  <button data-command-id="shell.customize-workflow" id="customize-btn" type="button" hidden data-tip="Fork this workflow to edit it yourself — takes it off the FloLess update channel">Customize…</button>
150
150
  <button id="compile-btn" data-command-id="workflow.compile" data-acts="Acts on the whole workflow" data-tip="Compile + approve → freeze the .lock">⎙ Compile</button>
151
151
  <button id="sim-btn" data-command-id="workflow.simulate" data-acts="Acts on the workflow only — never the live host" data-tip="Simulate: stub every node from its output schema — no live host is contacted. Validates the workflow's composition end-to-end, even when the real tools aren't connected yet.">Simulate</button>
@@ -726,18 +726,20 @@
726
726
  </div>
727
727
  </div>
728
728
 
729
- <!-- Workflow update: a FloLess-published workflow has a newer version. The changelog (entries
730
- newer than installed) renders into #wf-update-changelog; "Back up & update" swaps the
731
- structure but keeps the user's data (re-baked from the contract store). -->
729
+ <!-- Workflow update (one click, owner ruling 2026-11-02): what is new in the open workflow (#wf-update-changelog),
730
+ the same row the status-bar dialog shows (#wf-update-row: where it stands, the warning when the person changed
731
+ it), and one button that does the next thing: Update, then Undo (or Approve model for a Steel Model). -->
732
732
  <div class="modal-backdrop" id="wf-update-modal">
733
733
  <div class="modal">
734
734
  <div class="modal-title" id="wf-update-title">Workflow update</div>
735
735
  <div class="modal-sub" id="wf-update-sub"></div>
736
736
  <div class="wf-update-changelog" id="wf-update-changelog"></div>
737
- <div class="wf-update-note">Your work is safe — this updates the workflow's steps and keeps your data. A backup of the current version is saved first.</div>
737
+ <div id="wf-update-row" class="wf-update-row"></div>
738
+ <div id="wf-update-announce" class="sr-only" role="status" aria-live="polite"></div>
738
739
  <div class="modal-actions">
739
740
  <button data-command-id="shell.dialog-cancel#the workflow update" id="wf-update-cancel">Not now</button>
740
- <button data-command-id="shell.workflow-update-apply" id="wf-update-ok" class="primary">↑ Back up &amp; update</button>
741
+ <button data-command-id="shell.workflow-update-keep-mine#the open workflow" id="wf-update-ai" type="button" hidden data-tip="Asks the AI chat to bring your changes into the new version. Nothing changes until you send it.">Keep my changes (AI)</button>
742
+ <button data-command-id="shell.workflow-update-apply#the open workflow" data-command-instance-label="the open workflow" id="wf-update-ok" class="primary">Update</button>
741
743
  </div>
742
744
  </div>
743
745
  </div>
@@ -16,13 +16,14 @@
16
16
  });
17
17
  };
18
18
  const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
19
+ const toast = (msg, kind) => { if (typeof window.showToast === 'function') window.showToast(msg, kind); };
19
20
  const PAGE = 100;
20
21
 
21
22
  /** The areas, in the order the owner ruled ("By area", 2026-10-24). A kind this build doesn't name is Other activity. */
22
23
  const AREAS = [
23
24
  { key: 'project', label: 'Project', test: (k) => k === 'project-created' },
24
25
  { key: 'knowledge', label: 'Knowledge', test: (k) => k.startsWith('knowledge-') || k.startsWith('design-set-') || k.startsWith('design-issue-') },
25
- { key: 'workflows', label: 'Workflows', test: (k) => k.startsWith('workflow-') },
26
+ { key: 'workflows', label: 'Workflows', test: (k) => k.startsWith('workflow-') || k.startsWith('watcher-') },
26
27
  { key: 'rfis', label: 'RFIs', test: (k) => k.startsWith('rfi-') },
27
28
  { key: 'linked', label: 'Linked projects', test: (k) => k === 'module-linked' || k === 'module-unlinked' },
28
29
  { key: 'requests', label: 'Requests', test: (k) => k === 'request-changed' },
@@ -30,7 +31,7 @@
30
31
  const KNOWN = new Set(['project-created', 'knowledge-organized', 'knowledge-source-added', 'knowledge-source-removed',
31
32
  'design-set-registered', 'design-set-cleared', 'design-issue-added', 'design-issue-updated', 'design-issue-withdrawn',
32
33
  'design-issue-restored', 'workflow-created', 'workflow-compiled', 'workflow-run-finished', 'rfi-raised', 'rfi-answered',
33
- 'rfi-closed', 'module-linked', 'module-unlinked', 'request-changed']);
34
+ 'rfi-closed', 'module-linked', 'module-unlinked', 'request-changed', 'watcher-started', 'watcher-reported', 'watcher-stopped']);
34
35
  const OTHER = { key: 'other', label: 'Other activity' };
35
36
  const areaOf = (entry) => {
36
37
  const kind = String(entry?.event?.kind || '');
@@ -46,6 +47,11 @@
46
47
  };
47
48
  const ROUTINE_TIP = 'Started by a routine on its schedule, or by Run now on that routine.';
48
49
  const FAILED_TIP = 'This didn’t finish. Open the workflow or the request to see what went wrong, then try it again.';
50
+ // A watcher’s failed reaction or error stop (#2470 R6.5c): there is no request to open, and nothing to “try again” by hand.
51
+ const WATCHER_FAILED_TIPS = {
52
+ 'watcher-reported': 'This event wasn’t handled. Open the workflow to see what went wrong.',
53
+ 'watcher-stopped': 'The watcher stopped because of an error. Open the workflow to see what went wrong, then start it again.',
54
+ };
49
55
 
50
56
  const S = {
51
57
  loading: 'Reading history…',
@@ -92,7 +98,7 @@
92
98
  if (!st || st.identity !== identityOf(project)) {
93
99
  st = { identity: identityOf(project), projectId: project.id, uuid: null, rootId: null, entries: [], loaded: false,
94
100
  nextBefore: null, unavailable: '', error: '', stale: false, earlierError: false, cursorGone: false, earlierBusy: false, firstBusy: false,
95
- announce: '', query: '', open: new Map(), clicked: null, token: 0 };
101
+ announce: '', query: '', open: new Map(), expanded: new Set(), clicked: null, token: 0 };
96
102
  states.set(pane, st);
97
103
  }
98
104
  st.project = project;
@@ -130,22 +136,107 @@
130
136
  return `<span class="${a.pill ? 'rh-pill ph-author' : 'ph-author ph-author-you'}" tabindex="0" data-tip="${esc(a.tip)}" aria-label="${esc(a.aria)}">${esc(a.label)}</span>`;
131
137
  }
132
138
 
133
- function rowHtml(e) {
139
+ /* ── A watcher reaction's detail (#2470 R6.5c): the event as its source reported it, and what each step did ────── */
140
+
141
+ // The names a person reads for the fields a source commonly reports; any other field shows under its own name.
142
+ const FIELD_LABELS = { change: 'Change', type: 'Object type', mark: 'Mark', guid: 'GUID', host: 'Host', delivered_at: 'Raised at' };
143
+ const STEP_OUTCOMES = {
144
+ done: { label: 'Done', cls: 'rh-succeeded' },
145
+ report: { label: 'Made a report', cls: 'rh-succeeded' },
146
+ failed: { label: 'Failed', cls: 'rh-failed' },
147
+ unfinished: { label: 'Didn’t finish', cls: 'rh-stopped' },
148
+ };
149
+ const DETAIL_TIP = { show: 'Show what changed and what the workflow did', hide: 'Hide the details' };
150
+ const IN_DETAILS_TIP = 'Your search was found in this event’s details. Open the row to see it.';
151
+ const own = (map, key) => typeof key === 'string' && Object.prototype.hasOwnProperty.call(map, key);
152
+ const fieldLabel = (key) => (own(FIELD_LABELS, key) && FIELD_LABELS[key])
153
+ || (key.replace(/[_.-]+/g, ' ').replace(/([a-z0-9])([A-Z])/g, '$1 $2').trim().replace(/^./, (c) => c.toUpperCase()) || key);
154
+ const fieldValue = (key, value) => {
155
+ if (typeof value === 'boolean') return value ? 'yes' : 'no';
156
+ if (key === 'delivered_at' && typeof value === 'string') return when(value) || value;
157
+ return String(value);
158
+ };
159
+
160
+ /**
161
+ * The detail a row carries, or null: only a reaction row has one, and only one FloLess wrote with details. Read
162
+ * defensively, as a line in the file may have been edited by hand: only plain values of the expected types are kept.
163
+ */
164
+ function detailOf(e) {
165
+ const d = e?.event?.kind === 'watcher-reported' ? e.detail : null;
166
+ if (!d || typeof d !== 'object') return null;
167
+ const reported = d.reported && typeof d.reported === 'object' && !Array.isArray(d.reported)
168
+ ? Object.entries(d.reported).filter(([, v]) => typeof v === 'string' || typeof v === 'boolean' || (typeof v === 'number' && Number.isFinite(v))) : [];
169
+ const steps = (Array.isArray(d.steps) ? d.steps : [])
170
+ .filter((s) => s && typeof s === 'object' && typeof s.node === 'string' && own(STEP_OUTCOMES, s.outcome))
171
+ .map((s) => ({ node: s.node, outcome: s.outcome, error: typeof s.error === 'string' ? s.error : '' }));
172
+ const count = (n) => (Number.isSafeInteger(n) && n > 0 ? n : 0);
173
+ const more = count(d.moreSteps);
174
+ const moreFields = count(d.moreFields);
175
+ return reported.length || steps.length || more || moreFields ? { reported, steps, more, moreFields } : null;
176
+ }
177
+
178
+ const detailWords = (d) => (d ? [
179
+ ...d.reported.flatMap(([k, v]) => [fieldLabel(k), fieldValue(k, v)]),
180
+ ...d.steps.flatMap((s) => [s.node, STEP_OUTCOMES[s.outcome].label, s.error || '']),
181
+ ].join(' ') : '');
182
+
183
+ function detailHtml(e, d, open) {
184
+ const kv = (d.reported.length
185
+ ? `<dl class="ph-kv">${d.reported.map(([k, v]) => `<dt>${esc(fieldLabel(k))}</dt><dd>${esc(fieldValue(k, v))}</dd>`).join('')}</dl>`
186
+ : d.moreFields ? '' : '<p class="ph-sub-note">The source reported no details.</p>')
187
+ + (d.moreFields ? `<p class="ph-sub-note">${d.moreFields} more field${d.moreFields === 1 ? ' wasn’t' : 's weren’t'} kept, to keep the history small.</p>` : '');
188
+ const steps = d.steps.length
189
+ ? `<ol class="ph-steps">${d.steps.map((s) => {
190
+ const o = STEP_OUTCOMES[s.outcome];
191
+ return `<li class="ph-step"><span class="ph-step-id">Step “${esc(s.node)}”</span><span class="rh-outcome ${o.cls}">${esc(o.label)}</span>`
192
+ + (s.outcome === 'failed' && s.error ? `<p class="ph-step-err">${esc(s.error)}</p>` : '') + '</li>';
193
+ }).join('')}${d.more ? `<li class="ph-sub-note">and ${d.more} more step${d.more === 1 ? '' : 's'}</li>` : ''}</ol>`
194
+ : d.more
195
+ ? `<p class="ph-sub-note">${d.more} step${d.more === 1 ? ' wasn’t' : 's weren’t'} kept, to keep the history small.</p>`
196
+ : '<p class="ph-sub-note">No steps after the source were recorded.</p>';
197
+ const workflowId = typeof e.event?.workflowId === 'string' ? e.event.workflowId : '';
198
+ const open_ = workflowId
199
+ ? `<div class="ph-detail-actions"><button type="button" class="btn-mini rh-btn" data-ph-act="open-workflow" data-ph-workflow="${esc(workflowId)}"`
200
+ + ` data-command-id="shell.project-history-open#${esc(e.id)}" data-command-instance-label="${esc(when(e.at))}"`
201
+ + ' data-tip="Opens this workflow. Its Execution tab shows the run.">Open workflow</button></div>'
202
+ : '';
203
+ return `<div class="ph-detail" id="ph-d-${esc(e.id)}"${open ? '' : ' hidden'}>`
204
+ + `<section><h4 class="ph-sub-h">What changed</h4>${kv}</section>`
205
+ + `<section><h4 class="ph-sub-h">What the workflow did</h4>${steps}</section>${open_}</div>`;
206
+ }
207
+
208
+ function rowHtml(e, st, opts) {
134
209
  const failed = e.event?.outcome === 'failed';
210
+ const d = detailOf(e);
211
+ const open = !!d && st.expanded.has(e.id);
135
212
  const labels = [
213
+ opts.inDetails ? `<span class="rh-pill" tabindex="0" data-tip="${esc(IN_DETAILS_TIP)}">In details</span>` : '',
136
214
  authorHtml(e.actor),
137
- failed ? `<span class="rh-outcome rh-failed" tabindex="0" data-tip="${esc(FAILED_TIP)}">Failed</span>` : '',
215
+ failed ? `<span class="rh-outcome rh-failed" tabindex="0" data-tip="${esc(WATCHER_FAILED_TIPS[e.event?.kind] || FAILED_TIP)}">Failed</span>` : '',
138
216
  e.event?.trigger === 'routine' ? `<span class="rh-pill" tabindex="0" data-tip="${esc(ROUTINE_TIP)}">Routine</span>` : '',
139
217
  ].join('');
218
+ // The toggle's name stays the same; its state is aria-expanded. A list with any toggle keeps every time aligned.
219
+ const toggle = d
220
+ ? `<button type="button" class="ph-toggle" aria-expanded="${open}" aria-controls="ph-d-${esc(e.id)}"`
221
+ + ` aria-label="${esc(`Details: ${e.text || 'event'}, ${when(e.at)}`)}" data-tip="${esc(open ? DETAIL_TIP.hide : DETAIL_TIP.show)}"`
222
+ + ` data-ph-act="detail" data-ph-id="${esc(e.id)}" data-command-id="shell.project-history-detail#${esc(e.id)}"`
223
+ + ` data-command-instance-label="${esc(when(e.at))}"><span class="hd-caret" aria-hidden="true">▸</span></button>`
224
+ : (opts.slot ? '<span class="ph-toggle-slot" aria-hidden="true"></span>' : '');
140
225
  // The sentence is set as text after the markup is in place (paintList): it is the server's words, never markup.
141
226
  return `<div class="ph-row${failed ? ' is-failed' : ''}" role="listitem" data-ph-entry="${esc(e.id)}">`
142
- + `<time class="rh-when" datetime="${esc(e.at)}">${esc(when(e.at))}</time>`
227
+ + `<span class="ph-when">${toggle}<time class="rh-when" datetime="${esc(e.at)}">${esc(when(e.at))}</time></span>`
143
228
  + '<span class="ph-text"></span>'
144
- + `<span class="ph-labels">${labels}</span></div>`;
229
+ + `<span class="ph-labels">${labels}</span>${d ? detailHtml(e, d, open) : ''}</div>`;
145
230
  }
146
231
 
147
232
  const authorLabel = (e) => AUTHORS[e.actor]?.label || '';
148
- const matches = (e, area, terms) => terms.every((t) => `${e.text || ''} ${area.label} ${authorLabel(e)}`.toLowerCase().includes(t));
233
+ const rowWords = (e, area) => `${e.text || ''} ${area.label} ${authorLabel(e)}`.toLowerCase();
234
+ // A row matches when every term is in its sentence, area, author or — for a reaction — its details.
235
+ const matches = (e, area, terms) => {
236
+ const words = `${rowWords(e, area)} ${detailWords(detailOf(e)).toLowerCase()}`;
237
+ return terms.every((t) => words.includes(t));
238
+ };
239
+ const onlyInDetails = (e, area, terms) => terms.length > 0 && !terms.every((t) => rowWords(e, area).includes(t));
149
240
 
150
241
  function paint(pane) {
151
242
  const st = states.get(pane);
@@ -206,7 +297,9 @@
206
297
  + `<span class="ws-archived-caret hd-caret" aria-hidden="true">▸</span><span class="rh-sum-name">${esc(area.label)}</span>`
207
298
  + `<span class="rh-sum-meta">${rows.length} event${rows.length === 1 ? '' : 's'}</span>`
208
299
  + `<span class="rh-sum-meta">Latest ${esc(when(rows[0].at))}</span></summary>`
209
- + `<div class="rh-list ph-list" role="list" aria-label="${esc(`${area.label} events`)}">${rows.map(rowHtml).join('')}</div></details>`;
300
+ + `<div class="rh-list ph-list" role="list" aria-label="${esc(`${area.label} events`)}">`
301
+ + rows.map((e) => rowHtml(e, st, { slot: rows.some((r) => detailOf(r)), inDetails: onlyInDetails(e, area, terms) })).join('')
302
+ + '</div></details>';
210
303
  }).join('');
211
304
  const byId = new Map(st.entries.map((e) => [e.id, e]));
212
305
  host.querySelectorAll('[data-ph-entry]').forEach((row) => { row.querySelector('.ph-text').textContent = byId.get(row.dataset.phEntry)?.text || ''; });
@@ -260,7 +353,7 @@
260
353
  const uuid = body.project?.uuid ?? null;
261
354
  const rootId = body.rootId ?? null;
262
355
  // Another incarnation or Workspace folder than the rows shown: what the person opened or closed was about those.
263
- if (st.loaded && (uuid !== st.uuid || rootId !== st.rootId)) st.open = new Map();
356
+ if (st.loaded && (uuid !== st.uuid || rootId !== st.rootId)) { st.open = new Map(); st.expanded = new Set(); }
264
357
  st.error = '';
265
358
  st.stale = false;
266
359
  st.loaded = true;
@@ -317,6 +410,32 @@
317
410
  else if (fresh.length) pane.querySelector(`[data-ph-entry="${CSS.escape(fresh[0].id)}"]`)?.closest('details')?.querySelector('summary')?.focus({ preventScroll: true });
318
411
  }
319
412
 
413
+ // Opened or closed in place (no repaint, so focus, scroll and a half-made selection stay), and remembered for repaints.
414
+ function toggleDetail(pane, st, button) {
415
+ const id = button.dataset.phId;
416
+ const panel = pane.querySelector(`#${CSS.escape(`ph-d-${id}`)}`);
417
+ if (!id || !panel) return;
418
+ const open = button.getAttribute('aria-expanded') !== 'true';
419
+ if (open) st.expanded.add(id); else st.expanded.delete(id);
420
+ button.setAttribute('aria-expanded', String(open));
421
+ button.dataset.tip = open ? DETAIL_TIP.hide : DETAIL_TIP.show;
422
+ panel.hidden = !open;
423
+ }
424
+
425
+ let opening = false;
426
+ async function openWorkflow(workflowId) {
427
+ if (opening || !workflowId) return;
428
+ opening = true;
429
+ try {
430
+ const b = bridge();
431
+ if (typeof b.openOwnedWorkflow !== 'function') throw new Error('this window cannot open workflows');
432
+ await b.openOwnedWorkflow(workflowId);
433
+ } catch (error) {
434
+ console.warn('[project-history] a workflow could not be opened', error);
435
+ toast('FloLess couldn’t open that workflow. It may have been archived or removed since. Open it from the project’s Workflows step.', 'warn');
436
+ } finally { opening = false; }
437
+ }
438
+
320
439
  const wired = new WeakSet();
321
440
  function wire(pane) {
322
441
  if (wired.has(pane)) return;
@@ -333,6 +452,8 @@
333
452
  if (event.target.closest('.rh-summary')) st.clicked = event.target.closest('.ph-section')?.dataset.phArea ?? null;
334
453
  const act = event.target.closest('[data-ph-act]');
335
454
  if (!act) return;
455
+ if (act.dataset.phAct === 'detail') { toggleDetail(pane, st, act); return; }
456
+ if (act.dataset.phAct === 'open-workflow') { void openWorkflow(act.dataset.phWorkflow); return; }
336
457
  if (act.dataset.phAct === 'retry') { st.error = ''; const read = loadFirst(pane); paint(pane); void read; }
337
458
  else if (act.dataset.phAct === 'earlier') void loadEarlier(pane);
338
459
  else if (act.dataset.phAct === 'reread') { st.cursorGone = false; const read = loadFirst(pane); paint(pane); void read; }
@@ -30,6 +30,7 @@
30
30
  */
31
31
  import { planViewId } from './steel-plan-view-id.js';
32
32
  import { createMemberPresenceIndex, memberPresence } from './steel-model-v2-projection.js';
33
+ import { FT_IN, formatElevation, normalizeDisplayUnits, parseElevationMm } from './display-units.js';
33
34
 
34
35
  const AI_ID = /^[0-9a-f]{12}$/;
35
36
  const DIGEST = /^[0-9a-f]{64}$/;
@@ -67,6 +68,7 @@ export function subjectOk(v) {
67
68
  case 'connection': return only(v, ['channel', 'jointId', 'covers']) && str(v.jointId, ID_MAX) && coversOk(v.covers);
68
69
  case 'unmodelled-detail': return only(v, ['channel', 'sheetId', 'detailRef']) && str(v.sheetId, ID_MAX) && str(v.detailRef, ID_MAX);
69
70
  case 'filter': return only(v, ['channel', 'checkpointDigest']) && typeof v.checkpointDigest === 'string' && DIGEST.test(v.checkpointDigest);
71
+ case 'scope': return only(v, ['channel', 'keptDigest']) && typeof v.keptDigest === 'string' && DIGEST.test(v.keptDigest);
70
72
  default: return false;
71
73
  }
72
74
  }
@@ -83,6 +85,15 @@ export function valueOk(subject, v) {
83
85
  if (v.exclusionDigest !== null && (typeof v.exclusionDigest !== 'string' || !DIGEST.test(v.exclusionDigest))) return false;
84
86
  return nonNegInt(v.valueCount) && !(v.exclusionDigest === null && v.valueCount !== 0);
85
87
  }
88
+ case 'scope': {
89
+ // `parseScopeDecisionValue`'s shape (#2554 kind 2); the server alone wrote it.
90
+ if (!isObj(v) || !only(v, ['keptDigest', 'kept', 'attached', 'leaveOut']) || v.keptDigest !== subject.keptDigest) return false;
91
+ if (!nonNegInt(v.kept) || !nonNegInt(v.attached) || v.kept < 1 || !Array.isArray(v.leaveOut) || v.leaveOut.length < 1) return false;
92
+ return v.kept + v.leaveOut.length === v.attached && new Set(v.leaveOut.map((f) => isObj(f) && f.sha256)).size === v.leaveOut.length
93
+ && v.leaveOut.every((f) => isObj(f) && only(f, ['sha256', 'ext', 'bytes', 'names'])
94
+ && typeof f.sha256 === 'string' && DIGEST.test(f.sha256) && typeof f.ext === 'string' && /^[a-z0-9]{1,8}$/.test(f.ext)
95
+ && Number.isSafeInteger(f.bytes) && f.bytes > 0 && Array.isArray(f.names) && f.names.length > 0 && f.names.every((n) => str(n, 260)));
96
+ }
86
97
  case 'setup':
87
98
  if (!isObj(v)) return false;
88
99
  if (subject.row === 'scale') return only(v, ['mmPerPx']) && finite(v.mmPerPx) && v.mmPerPx > 0;
@@ -99,6 +110,39 @@ function entryOk(entry) {
99
110
  && subjectOk(entry.subject) && entry.subject.channel === entry.channel && valueOk(entry.subject, entry.value);
100
111
  }
101
112
 
113
+ // A length that names its own unit, at the very start of the AI's text: `8359.5 mm`, `8.36 m`, `27'-5 1/8"`, `28'`. It
114
+ // must END there (end of text, a space or punctuation): `28'-0 (top)` is not the length `28'` followed by "-0".
115
+ const LEAD_END = String.raw`(?=$|[\s,.;:()])`;
116
+ const LEAD_METRIC = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*(?:mm|m)` + LEAD_END, 'i');
117
+ const LEAD_FT_IN = new RegExp(String.raw`^[+-]?\d+(?:\.\d+)?\s*'(?:\s*-?\s*(?:\d+\s+)?\d+(?:\.\d+|\/\d+)?\s*")?` + LEAD_END);
118
+ /** How far a written length may sit from the recorded value and still be that value: 0.5 mm, or 1/16". */
119
+ const LEAD_TOLERANCE_MM = { metric: 0.5, imperial: 1.6 };
120
+
121
+ /**
122
+ * #2998: an AI decision's `chosen` as the person reads it. The AI writes `chosen` in its own words and may give a height
123
+ * in millimetres in a ft-in project ("8359.5 mm, interpolated between the callouts either side"), while the decision
124
+ * also records the exact value (`value.mm`). When the text STARTS with a length in the other unit system that equals
125
+ * that value, the length is shown in the project's units ("27'-5 1/8", interpolated …") and the original is returned
126
+ * as `wrote` for a tooltip. Anything else — no recorded value, a length that does not match it, a length already in the
127
+ * project's units, a length later in the text — is returned exactly as the AI wrote it: only the unit changes, never a
128
+ * number. Display only; the recorded text is untouched.
129
+ *
130
+ * @param {unknown} chosen @param {unknown} value the decision's `value` @param {unknown} units the project's display units
131
+ * @returns {{ text: string, wrote?: string }}
132
+ */
133
+ export function decisionChoiceInUnits(chosen, value, units) {
134
+ const text = typeof chosen === 'string' ? chosen : '';
135
+ if (!isObj(value) || !finite(value.mm)) return { text };
136
+ const shown = normalizeDisplayUnits(units);
137
+ const metric = LEAD_METRIC.exec(text), imperial = metric ? null : LEAD_FT_IN.exec(text);
138
+ const lead = metric || imperial;
139
+ if (!lead || (metric ? shown !== FT_IN : shown === FT_IN)) return { text };
140
+ const mm = parseElevationMm(lead[0], shown);
141
+ if (mm == null || Math.abs(mm - value.mm) > LEAD_TOLERANCE_MM[metric ? 'metric' : 'imperial']) return { text };
142
+ const wrote = lead[0].trim();
143
+ return { text: formatElevation(value.mm, shown) + text.slice(lead[0].length), wrote };
144
+ }
145
+
102
146
  /**
103
147
  * @param {unknown} model a steel.model/v2 document (the editor's `C`)
104
148
  */
@@ -194,7 +238,7 @@ export function aiDecisionMarksOf(model) {
194
238
  }
195
239
  break;
196
240
  }
197
- default: // filter, audit-gap, unmodelled-detail: they bear on the whole model
241
+ default: // filter, scope, audit-gap, unmodelled-detail: they bear on the whole model
198
242
  note.push({ decisionId: id, channel: entry.channel, reason: 'model' });
199
243
  }
200
244
  }