@floless/app 0.167.0 → 0.169.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 (277) hide show
  1. package/autostart.mjs +169 -63
  2. package/cli-actions.mjs +8 -1
  3. package/desktop-shell.mjs +335 -0
  4. package/dist/floless-server.cjs +73121 -55759
  5. package/dist/schemas/steel.model.v2.schema.json +2 -1
  6. package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
  7. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
  8. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  9. package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -2
  10. package/dist/skills/floless-app-ui/SKILL.md +2 -2
  11. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  12. package/dist/templates/college-phase-exporter.flo +7 -2
  13. package/dist/templates/trimble-list-projects.flo +10 -2
  14. package/dist/web/agent-steps.js +2 -2
  15. package/dist/web/agents.js +50 -14
  16. package/dist/web/app.css +209 -11
  17. package/dist/web/app.js +99 -16
  18. package/dist/web/aware-update-client.js +14 -6
  19. package/dist/web/aware.js +583 -69
  20. package/dist/web/chat.css +12 -1
  21. package/dist/web/chat.js +627 -96
  22. package/dist/web/commands-drawing-check.js +3 -0
  23. package/dist/web/commands-filter.js +5 -5
  24. package/dist/web/commands-shell.js +283 -14
  25. package/dist/web/commands-steel.js +9 -2
  26. package/dist/web/commands-vector.js +69 -0
  27. package/dist/web/desktop-window.js +435 -0
  28. package/dist/web/drawing-check-editor.html +10 -0
  29. package/dist/web/drawing-check-editor.js +515 -187
  30. package/dist/web/failure-copy.js +33 -2
  31. package/dist/web/flo-3d.js +310 -0
  32. package/dist/web/flo-card.js +72 -0
  33. package/dist/web/guide.js +78 -10
  34. package/dist/web/index.html +90 -10
  35. package/dist/web/instructor.js +4 -1
  36. package/dist/web/leave-guard.js +347 -14
  37. package/dist/web/model-editor-steel-adapter.js +41 -1
  38. package/dist/web/model-viewport-toolbar.js +11 -0
  39. package/dist/web/pages.js +21 -14
  40. package/dist/web/panels.js +5 -2
  41. package/dist/web/pdf-view.js +421 -0
  42. package/dist/web/project-history.js +3 -2
  43. package/dist/web/project-modules.js +5 -3
  44. package/dist/web/project-reconciliation.js +1 -1
  45. package/dist/web/project-rfis.js +4 -2
  46. package/dist/web/project-workflows.js +8 -4
  47. package/dist/web/reference-geometry-worker.js +11 -2
  48. package/dist/web/renderers.js +6 -0
  49. package/dist/web/report-csp.js +68 -0
  50. package/dist/web/revit-editor.html +1 -0
  51. package/dist/web/revit-editor.js +37 -8
  52. package/dist/web/run-history.js +2 -3
  53. package/dist/web/shared-prefs.js +364 -0
  54. package/dist/web/steel-3d-flo.js +309 -0
  55. package/dist/web/steel-3d-view.js +159 -0
  56. package/dist/web/steel-editor.html +329 -47
  57. package/dist/web/steel-filter-flo.js +74 -18
  58. package/dist/web/steel-filter.html +22 -6
  59. package/dist/web/tab-signal.js +36 -1
  60. package/dist/web/tekla-editor.html +1 -0
  61. package/dist/web/terminal-requests.js +78 -0
  62. package/dist/web/tool-updates.js +160 -38
  63. package/dist/web/vector-3d.html +14 -3
  64. package/dist/web/vector-editor.html +60 -10
  65. package/dist/web/vendor/README.md +23 -0
  66. package/dist/web/vendor/pdfjs/LICENSE +177 -0
  67. package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  68. package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  69. package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  70. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  71. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  72. package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  73. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  74. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  75. package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  76. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  77. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  78. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  79. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  80. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  81. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  82. package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  83. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  84. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  85. package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  86. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  87. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  88. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  89. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  90. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  91. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  92. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  93. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  94. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  95. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  96. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  97. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  98. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  99. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  100. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  101. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  102. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  103. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  104. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  105. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  106. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  107. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  108. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  109. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  110. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  111. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  112. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  113. package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  114. package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  115. package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  116. package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  117. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  118. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  119. package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  120. package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  121. package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  122. package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  123. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  124. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  125. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  126. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  127. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  128. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  129. package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  130. package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  131. package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  132. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  133. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  134. package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  135. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  136. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  137. package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  138. package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  139. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  140. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  141. package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  142. package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  143. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  144. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  145. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  146. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  147. package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  148. package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  149. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  150. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  151. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  152. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  153. package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
  154. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  155. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  156. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  157. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  158. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  159. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  160. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  161. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  162. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  163. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  164. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  165. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  166. package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  167. package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  168. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  169. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  170. package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  171. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  172. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  173. package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  174. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  175. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  176. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  177. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  178. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  179. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  180. package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  181. package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
  182. package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  183. package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  184. package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  185. package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  186. package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  187. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  188. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  189. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  190. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  191. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  192. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  193. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  194. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  195. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  196. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  197. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  198. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  199. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  200. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  201. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  202. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  203. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  204. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  205. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  206. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  207. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  208. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  209. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  210. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  211. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  212. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  213. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  214. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  215. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  216. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  217. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  218. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  219. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  220. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  221. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  222. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  223. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  224. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  225. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  226. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  227. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  228. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  229. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  230. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  231. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  232. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  233. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  234. package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
  235. package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  236. package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  237. package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
  238. package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
  239. package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
  240. package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  241. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  242. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  243. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  244. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  245. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  246. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  247. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  248. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  249. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  250. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  251. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  252. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  253. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  254. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  255. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  256. package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  257. package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  258. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  259. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  260. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  261. package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  262. package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  263. package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
  264. package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  265. package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
  266. package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  267. package/dist/web/workspace-root-management.js +1 -1
  268. package/dist/web/workspaces.js +792 -165
  269. package/home-env.mjs +28 -0
  270. package/install-path.mjs +59 -3
  271. package/launch-starting-page.mjs +35 -15
  272. package/launch.mjs +363 -51
  273. package/package.json +9 -8
  274. package/pin-home.mjs +6 -0
  275. package/post-update-marker.mjs +14 -0
  276. package/preferences-file.mjs +289 -0
  277. package/supervisor-lock.mjs +195 -0
@@ -18,13 +18,12 @@
18
18
  const { timeoutMs, ...requestOptions } = opts;
19
19
  if (!requestOptions.signal && Number.isFinite(timeoutMs)) requestOptions.signal = AbortSignal.timeout(timeoutMs);
20
20
  const res = await fetch(path, { headers: { 'content-type': 'application/json' }, ...requestOptions });
21
- const body = await res.json().catch(() => ({
22
- ok: false,
23
- code: 'response-unreadable',
24
- error: `FloLess received an unreadable response (HTTP ${res.status}).`,
25
- }));
21
+ // An answer that is not FloLess's JSON keeps its code; the sentence comes from failureCopy below, never the status.
22
+ const body = await res.json().catch(() => ({ ok: false, code: 'response-unreadable' }));
26
23
  if (!res.ok || body.ok === false) {
27
- const e = new Error(body.error || `HTTP ${res.status}`);
24
+ // #3097: the server's own sentence when it wrote one, else the shared one; never "HTTP <status>".
25
+ const readOnly = /^(GET|HEAD)$/.test(String(requestOptions.method || 'GET').toUpperCase());
26
+ const e = new Error(personText(body) || failureCopy({ status: res.status, body }, { retrySafe: readOnly }).text);
28
27
  e.body = body;
29
28
  e.status = res.status;
30
29
  throw e;
@@ -307,6 +306,7 @@
307
306
  const $companyKnowledgeList = document.getElementById('company-knowledge-list');
308
307
  const $companyKnowledgeConfirm = document.getElementById('company-knowledge-confirm');
309
308
  const $companyKnowledgeError = document.getElementById('company-knowledge-error');
309
+ const $companyKnowledgeStatus = document.getElementById('company-knowledge-status');
310
310
  const $companyKnowledgeClose = document.getElementById('company-knowledge-close');
311
311
  const $companyKnowledgeCancel = document.getElementById('company-knowledge-cancel');
312
312
  const $companyKnowledgeAction = document.getElementById('company-knowledge-action');
@@ -668,6 +668,15 @@
668
668
  * so it says "something newer happened", not "a newer EXPORTS render happened". (Review round 4.)
669
669
  */
670
670
  let exportsRenderGen = 0;
671
+ // #3139: the latest Exports render's lifecycle check ran out of time, so the gate says it could not check (with a
672
+ // retry) instead of "Checking…" or a "Nothing to export yet" that FloLess never confirmed.
673
+ let exportsLifecycleUnanswered = false;
674
+ // Which lifecycle answer the Exports gate was last painted with, and the Exports render waiting on its lifecycle
675
+ // check (0 when none) — see syncExportsLifecycleGate.
676
+ let exportsPaintedGate = '';
677
+ let exportsLifecycleWait = 0;
678
+ // #3139: an answer handed to the render syncExportsLifecycleGate redoes ({ gen, present }), so it is not asked again.
679
+ let exportsLifecycleHanded = null;
671
680
  let exportState = null; // kind → { path, exportedAt } after a successful list; null = unknown/failed
672
681
  // #2449: { version, hash } of the approved version exportState's files came from, from the SAME listing; null = unknown.
673
682
  let exportStateFrom = null;
@@ -1226,9 +1235,10 @@
1226
1235
  */
1227
1236
  let projectContractLifecycle = 'unknown';
1228
1237
  // A General project (#2470) has no Model, Exports or History step, so nothing the person clicks would
1229
- // ever re-ask a lifecycle check that timed out or failed. It re-asks by itself, a few times, further
1230
- // apart each time; then the header says it could not check rather than "Checking…" forever.
1231
- const SOURCELESS_PRESENCE_RETRIES = 3;
1238
+ // ever re-ask a lifecycle check that timed out or failed. It re-asks by itself once more; then the header says it
1239
+ // could not check rather than "Checking…" forever. Once, because each check already keeps trying for its own 45 s
1240
+ // budget (#3139): three re-asks made a hung server read "Checking project…" for over three minutes.
1241
+ const SOURCELESS_PRESENCE_RETRIES = 1;
1232
1242
  let sourcelessPresence = { projectId: null, openSeq: 0, tries: 0, gaveUp: false, timer: null };
1233
1243
  let exportsHasModel = false;
1234
1244
  // A project may open on Model/Exports/History while its lifecycle probe is still in flight. Keep
@@ -1243,7 +1253,7 @@
1243
1253
  * re-disable Approve on a project that now has a model. Every writer bumps it; older results drop. */
1244
1254
  let modelPresenceGen = 0;
1245
1255
  // One lifecycle request per open project. Tab clicks attach to this promise instead of starting
1246
- // competing four-second probes whose generation guards make all but the last answer disappear.
1256
+ // competing probes (each keeps trying for up to 45 s) whose generation guards make all but the last answer disappear.
1247
1257
  let modelPresenceProbe = null;
1248
1258
 
1249
1259
  /** The header's AUTHORED tooltip, captured from the static markup so the has-a-model state restores
@@ -1749,7 +1759,8 @@
1749
1759
  // Remember WHY, so renderLanding can say "couldn't load" instead of "none yet" (they look
1750
1760
  // identical from `projects` alone). Cleared on the next success, so a recovered load drops
1751
1761
  // straight back to the normal empty state.
1752
- projectsLoadError = (err && err.message) || String(err);
1762
+ // The error itself, not only its text: #3097 took the status out of the text, and the hint still reads it.
1763
+ projectsLoadError = err || new Error('projects could not be loaded');
1753
1764
  if (!(opts && opts.quiet)) showToast('Couldn’t load projects. Check the Workspace directory and try again.', 'warn');
1754
1765
  }
1755
1766
  // Paint the moment the LIST is in hand — before the archived call, not after it. That call is a
@@ -2430,10 +2441,11 @@
2430
2441
  // the Knowledge viewer. Returns '' for anything unrecognised — better to show only the raw detail
2431
2442
  // than to guess wrong about why. The raw string is shown either way, just demoted.
2432
2443
  function projectsErrorHint(reason) {
2433
- const r = String(reason || '').toLowerCase();
2434
- if (/subscription|session|sign in|402/.test(r)) return 'Your sign-in needs refreshing — sign in again, then retry.';
2444
+ const status = Number(reason && reason.status) || 0;
2445
+ const r = String((reason && reason.message) || reason || '').toLowerCase();
2446
+ if (status === 401 || status === 402 || /subscription|session|sign in|402/.test(r)) return 'Your sign-in needs refreshing — sign in again, then retry.';
2435
2447
  if (/failed to fetch|networkerror|load failed|econnrefused|connection/.test(r)) return 'The local server didn’t answer.';
2436
- if (/http 5\d\d/.test(r)) return 'The server hit an error listing them.';
2448
+ if (status >= 500 || /http 5\d\d/.test(r)) return 'The server hit an error listing them.';
2437
2449
  return '';
2438
2450
  }
2439
2451
 
@@ -2851,7 +2863,9 @@
2851
2863
  `<span class="ws-body"><span><span class="ws-name">${escapeHtml(p.name)}</span>` +
2852
2864
  (projectCapability ? `<span class="ws-meta">${escapeHtml(projectCapability)}</span>` : '') +
2853
2865
  // #2521 row 5: the card speaks for the WORKING COPY only, and says so in its tip.
2854
- (p.quick && quickPillHtml(p.quick) ? `<span class="ws-meta ws-quick">${quickPillHtml(p.quick, { scope: 'Working copy', focusable: false })}</span>` : '') +
2866
+ (p.quick && quickPillHtml(p.quick) ? `<span class="ws-meta ws-quick">${quickPillHtml(p.quick, { scope: 'Working copy', focusable: false })}${coveragePillHtml(p.coverage, { scope: 'Working copy', focusable: false, besides: p.quick })}</span>` : '') +
2867
+ // #2554 slice 2: a model that left drawing files unread says so beside its label, or on its own when precise.
2868
+ (!(p.quick && quickPillHtml(p.quick)) && p.coverage && coveragePillHtml(p.coverage) ? `<span class="ws-meta ws-quick">${coveragePillHtml(p.coverage, { scope: 'Working copy', focusable: false })}</span>` : '') +
2855
2869
  (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>` : '') +
2856
2870
  `<span class="ws-meta ws-registration-status"${p.registrationState === 'unavailable' ? '' : ' hidden'}>${escapeHtml(p.registrationReason || 'Project folder unavailable. Locate or restore it.')}</span>` +
2857
2871
  `<span class="ws-meta ws-registration-location-note"${p.registrationState !== 'unavailable' && p.registrationLocationWarning ? '' : ' hidden'}>${escapeHtml(p.registrationLocationWarning || '')}</span>` +
@@ -3469,12 +3483,21 @@
3469
3483
  const $teklaSourceStatus = document.getElementById('tekla-source-status');
3470
3484
  let teklaSourceChoice = null;
3471
3485
  let teklaSourcePicking = false;
3486
+ const TEKLA_SOURCE_BUSY_REASON = 'FloLess is still reading that model. This window updates when it is done.';
3472
3487
  function setTeklaSourcePicking(busy, message = '') {
3473
3488
  teklaSourcePicking = busy;
3474
3489
  $teklaSourceModal?.setAttribute('aria-busy', String(busy));
3475
3490
  if ($teklaSourceFolder) $teklaSourceFolder.disabled = busy;
3476
3491
  if ($teklaSourceZip) $teklaSourceZip.disabled = busy;
3477
- if ($teklaSourceCancel) $teklaSourceCancel.disabled = busy;
3492
+ if ($teklaSourceCancel) {
3493
+ $teklaSourceCancel.disabled = busy;
3494
+ if (busy) $teklaSourceCancel.dataset.blockedReason = TEKLA_SOURCE_BUSY_REASON;
3495
+ else delete $teklaSourceCancel.dataset.blockedReason;
3496
+ }
3497
+ // A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
3498
+ if (busy && document.activeElement?.disabled && $teklaSourceModal?.contains(document.activeElement)) {
3499
+ $teklaSourceDialog?.focus();
3500
+ }
3478
3501
  if ($teklaSourceStatus) {
3479
3502
  $teklaSourceStatus.textContent = message;
3480
3503
  $teklaSourceStatus.hidden = !message;
@@ -3493,6 +3516,11 @@
3493
3516
  $teklaSourceModal?.classList.remove('show');
3494
3517
  if (restoreFocus && state?.returnFocus?.isConnected) state.returnFocus.focus();
3495
3518
  }
3519
+ /** #3151: Cancel, Escape and the backdrop agree — none of them closes the window while a source is read. */
3520
+ function dismissTeklaSourceChoice() {
3521
+ if (teklaSourcePicking) { setTeklaSourcePicking(true, TEKLA_SOURCE_BUSY_REASON); return; }
3522
+ closeTeklaSourceChoice();
3523
+ }
3496
3524
  async function chooseTeklaSource(kind) {
3497
3525
  const choice = teklaSourceChoice;
3498
3526
  if (!choice || teklaSourcePicking) return;
@@ -3519,10 +3547,10 @@
3519
3547
  }
3520
3548
  $teklaSourceFolder?.addEventListener('click', () => { void chooseTeklaSource('folder'); });
3521
3549
  $teklaSourceZip?.addEventListener('click', () => { void chooseTeklaSource('zip'); });
3522
- $teklaSourceCancel?.addEventListener('click', () => closeTeklaSourceChoice());
3523
- $teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal) closeTeklaSourceChoice(); });
3550
+ $teklaSourceCancel?.addEventListener('click', () => dismissTeklaSourceChoice());
3551
+ $teklaSourceModal?.addEventListener('click', (event) => { if (event.target === $teklaSourceModal) dismissTeklaSourceChoice(); });
3524
3552
  $teklaSourceModal?.addEventListener('keydown', (event) => {
3525
- if (event.key === 'Escape') { event.preventDefault(); closeTeklaSourceChoice(); return; }
3553
+ if (event.key === 'Escape') { event.preventDefault(); dismissTeklaSourceChoice(); return; }
3526
3554
  if (event.key !== 'Tab') return;
3527
3555
  const controls = [...$teklaSourceModal.querySelectorAll('button:not([disabled])')];
3528
3556
  if (!controls.length) return;
@@ -5055,7 +5083,13 @@
5055
5083
  },
5056
5084
  });
5057
5085
  const uploaded = await upload.json().catch(() => ({}));
5058
- if (!upload.ok || uploaded.ok === false) throw new Error(uploaded.message || uploaded.error || `upload failed (${upload.status})`);
5086
+ // #3097: the server's own sentence when it wrote one, else the shared one; never "(<status>)".
5087
+ if (!upload.ok || uploaded.ok === false) {
5088
+ console.warn('[rvt] upload refused', upload.status, uploaded);
5089
+ throw Object.assign(new Error(uploaded.message || uploaded.error
5090
+ || failureCopy({ status: upload.status, body: uploaded }, { action: 'copy the RVT file to FloLess', unsure: 'Choose the RVT file again.' }).text),
5091
+ { status: upload.status, body: uploaded });
5092
+ }
5059
5093
  const receipt = uploaded.receipt;
5060
5094
  const started = await api('/api/model-imports', { method: 'POST', body: JSON.stringify({
5061
5095
  projectUuid: project.uuid, generation: receipt.generation, sourceSha256: receipt.sourceSha256,
@@ -5483,7 +5517,7 @@
5483
5517
  // reset below; until the new document says it is ready, no step message goes to the old one.
5484
5518
  editorBridge = null;
5485
5519
  // #1890: a new workspace conversation suggests this project's units (the one opened last).
5486
- try { localStorage.setItem('floless:last-project', p.id); } catch { /* private mode: no suggestion */ }
5520
+ try { if (window.flolessPrefs) window.flolessPrefs.set('lastProject', p.id); else localStorage.setItem('floless:last-project', p.id); } catch { /* private mode: no suggestion */ }
5487
5521
  revitSourceState = null;
5488
5522
  revitActiveOperation = null;
5489
5523
  // Project lifecycle is project-scoped. Reset it before the first setStep so one project's model
@@ -5560,7 +5594,7 @@
5560
5594
  frames.model.dataset.loaded = ''; frames.drawings.dataset.loaded = '';
5561
5595
  // Start the small lifecycle envelope BEFORE the heavier approval review request. Both hit the
5562
5596
  // same localhost event loop; sending approval first could keep the lifecycle request queued until
5563
- // its four-second client deadline, falsely leaving an existing model in the checking state. This
5597
+ // its client deadline, falsely leaving an existing model in the checking state. This
5564
5598
  // promise also owns every tab activation until it settles (refreshModelPresence deduplicates it).
5565
5599
  refreshModelPresence(p.id, p.app).catch((e) => {
5566
5600
  console.error('[workspaces] could not resolve model presence', e);
@@ -5618,18 +5652,20 @@
5618
5652
  }
5619
5653
  const gen = ++modelPresenceGen;
5620
5654
  const promise = (async () => {
5621
- const present = await projectContractState(projectId, appId);
5655
+ const present = await projectContractState(projectId, appId, () => gen === modelPresenceGen && current?.id === projectId);
5622
5656
  if (gen !== modelPresenceGen || !current || current.id !== projectId) return false; // superseded
5623
- const restore = pendingPresenceStep?.projectId === projectId ? pendingPresenceStep.step : '';
5657
+ // A step the person clicked is settled by applyModelPresence (settleAskedStep), whichever check answers it;
5658
+ // this restores only the step a project was opened on.
5659
+ const held = pendingPresenceStep?.projectId === projectId && !pendingPresenceStep.asked ? pendingPresenceStep.step : '';
5624
5660
  // A timeout/network error is not evidence that this project has no model. Keep the requested
5625
5661
  // destination so its next activation can retry the probe and restore it after recovery.
5626
- if (present !== 'unknown') pendingPresenceStep = null;
5662
+ if (present !== 'unknown' && held) pendingPresenceStep = null;
5627
5663
  applyModelPresence(present);
5628
5664
  // Restore only when this same project's authoritative answer says a model exists. A confirmed
5629
5665
  // preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
5630
5666
  // #2470 R6.5b: History on a kind with two views is never gated (its Activity view needs no model), so it is
5631
5667
  // restored on any known answer too, and opens on Activity when Approvals still has to wait.
5632
- if (restore && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && restore === 'history' && !stageGateFor(restore)))) setStep(restore);
5668
+ if (held && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && held === 'history' && !stageGateFor(held)))) setStep(held);
5633
5669
  return true;
5634
5670
  })();
5635
5671
  modelPresenceProbe = { projectId, promise };
@@ -5641,15 +5677,98 @@
5641
5677
 
5642
5678
  /** Push the answer to the flag AND the header together, so no two surfaces can disagree. */
5643
5679
  function applyModelPresence(present) {
5680
+ // #3139: which Exports render was already waiting on its check before this answer. Opening the clicked step below
5681
+ // can start a new render, which waits on its own check and must not be redone by the answer that opened it.
5682
+ const exportsWaiting = typeof exportsLifecycleWait === 'number' ? exportsLifecycleWait : 0;
5644
5683
  projectContractLifecycle = present;
5645
5684
  exportsHasModel = present === 'model';
5646
5685
  retrySourcelessPresence(present);
5647
5686
  renderApprovalHeader();
5687
+ // #3139, through `typeof` because harnesses lift this function alone. The clicked step first: before the gate
5688
+ // repaint, which may move the person off a tab the answer locked; and before the panes, because opening the step
5689
+ // hides the pane it was clicked from, so that pane is not redone behind it.
5690
+ if (typeof settleAskedStep === 'function') settleAskedStep(present);
5648
5691
  applyStageGating();
5649
5692
  // A lifecycle probe may resolve after the saved-filter card already painted under `unknown`.
5650
5693
  // Retire it in the same turn that reveals the replacement strip; waiting for the request poll
5651
5694
  // would briefly recreate the two competing status bands this hand-off exists to remove.
5652
5695
  if (currentStep === 'drawings' && lastRevState === 'pending') retireRevisionCardForStrip(revCardReq);
5696
+ if (typeof syncExportsLifecycleGate === 'function') syncExportsLifecycleGate(present, exportsWaiting);
5697
+ if (typeof syncHistoryLifecycleWait === 'function') syncHistoryLifecycleWait();
5698
+ }
5699
+
5700
+ /**
5701
+ * #3139: the step the person clicked while the lifecycle was unknown (deferStageUntilLifecycle marks it `asked`) is
5702
+ * settled by whichever check applies an answer — its own, or an Exports or History render's that overtook it, which
5703
+ * used to drop the click. A real answer opens it from wherever the person is (any later step choice would already
5704
+ * have dropped it, see dropAskedStep) or says which earlier stage it waits for; no answer says so once and offers
5705
+ * Try again, then lets the step go, so a much later check can never move the person (#1669).
5706
+ */
5707
+ function settleAskedStep(present) {
5708
+ const held = pendingPresenceStep;
5709
+ if (!held?.asked || !current || held.projectId !== current.id) return;
5710
+ pendingPresenceStep = null;
5711
+ if (pendingPresenceToast) pendingPresenceToast();
5712
+ pendingPresenceToast = null;
5713
+ const s = held.step;
5714
+ if (present === 'unknown') {
5715
+ const projectId = held.projectId;
5716
+ // Held as the pending toast, so a click on another step or another project closes it like the checking one.
5717
+ pendingPresenceToast = showToast(`Couldn’t check project stages, so ${stepLabel(s)} hasn’t opened yet. Your project is unchanged.`, 'warn', {
5718
+ persistent: true,
5719
+ action: { label: 'Try again', commandId: `shell.workspace-stage-recheck#${stepLabel(s)}`, onClick: () => { if (current?.id === projectId) chooseStep(s); } },
5720
+ });
5721
+ return;
5722
+ }
5723
+ // A confirmed preliminary answer turns the apparent availability into the real prerequisite gate. Reuse that
5724
+ // specific explanation instead of replacing it with generic readiness copy. History opens on its Activity view.
5725
+ const reason = stageGateFor(s);
5726
+ if (present === 'model' || (s === 'history' && !reason)) setStep(s);
5727
+ else if (reason) showToast(reason, 'warn');
5728
+ }
5729
+
5730
+ /** #3139: moves off a tab that just became locked. FloLess's move, not the person's, so a step they clicked stays held. */
5731
+ let stepRedirecting = false;
5732
+ function redirectStep(s) {
5733
+ stepRedirecting = true;
5734
+ try { setStep(s); } finally { stepRedirecting = false; }
5735
+ }
5736
+
5737
+ /**
5738
+ * #3139: the person (or the chat, or a "View" link) moved to another step by a route other than chooseStep, so a
5739
+ * step they clicked earlier is no longer what they want: drop it and its checking toast. Reached from setStep
5740
+ * through `typeof` (harnesses lift setStep alone). An open-time hold is not `asked` and is left alone, and so is a
5741
+ * move FloLess makes itself (redirectStep): that is not the person's choice.
5742
+ */
5743
+ function dropAskedStep() {
5744
+ if (stepRedirecting || !pendingPresenceStep?.asked) return;
5745
+ pendingPresenceStep = null;
5746
+ if (pendingPresenceToast) pendingPresenceToast();
5747
+ pendingPresenceToast = null;
5748
+ }
5749
+
5750
+ /**
5751
+ * #3139: whichever check settles — the Exports render's own, or another that overtook it (a General project's
5752
+ * re-check, a model-creating read, a step click) — a visible Exports pane shows that answer. An overtaken render
5753
+ * returned before loading the export sources, so it is redone in full, with this answer handed to it so it does not
5754
+ * ask the server again (after a check that gave up, that would put "Checking…" back beside "Couldn’t check");
5755
+ * otherwise the gate is repainted when its answer changed. `waitingBefore` is the render that was waiting before this
5756
+ * answer: one this answer itself started (by opening the clicked step) waits on its own check and is left to it.
5757
+ * Without this "Checking what this project holds…" or "Loading export sources…" outlived every check.
5758
+ */
5759
+ function syncExportsLifecycleGate(present, waitingBefore) {
5760
+ exportsLifecycleUnanswered = present === 'unknown';
5761
+ if (!current || $wsExports.hidden) return;
5762
+ if (exportsLifecycleWait && exportsLifecycleWait === exportsRenderGen && exportsLifecycleWait === waitingBefore) {
5763
+ exportsLifecycleWait = 0;
5764
+ exportsLifecycleHanded = { gen: exportsRenderGen + 1, present };
5765
+ safeRenderExports('after the project check finished');
5766
+ return;
5767
+ }
5768
+ if (exportsLifecycleGateKey() !== exportsPaintedGate) paintExports(current.approvedAt);
5769
+ }
5770
+ function exportsLifecycleGateKey() {
5771
+ return projectContractLifecycle + (exportsLifecycleUnanswered ? ':unanswered' : '');
5653
5772
  }
5654
5773
 
5655
5774
  /** Re-ask a General project's lifecycle after a check that settled `unknown` (see SOURCELESS_PRESENCE_RETRIES). */
@@ -6016,10 +6135,22 @@
6016
6135
  return !!l && typeof l === 'object' && typeof l.pageId === 'string' && FLO_HASH.test(l.sourceHash)
6017
6136
  && Number.isSafeInteger(l.pageNumber) && l.pageNumber >= 1 && Number.isSafeInteger(l.part) && l.part >= 0 && l.part <= 9
6018
6137
  && Number.isSafeInteger(l.seq) && Number.isFinite(l.ageMs) && l.ageMs >= 0
6138
+ && (l.tiles === undefined || (Number.isSafeInteger(l.tiles) && l.tiles >= 0 && l.tiles <= 16))
6019
6139
  && (l.rect === null || (Array.isArray(l.rect) && l.rect.length === 4 && l.rect.every((v) => Number.isFinite(v) && v >= 0 && v <= 1)
6020
6140
  && l.rect[2] > l.rect[0] && l.rect[3] > l.rect[1]));
6021
6141
  }
6022
6142
 
6143
+ /**
6144
+ * #3093: the sheets the read was handed a picture of (`steelSeen`), when it is well formed; else null, and Flo says no
6145
+ * count. `whole` is false when the list may be missing some (the server restarted, or forgot looks to make room).
6146
+ */
6147
+ function floSeenOk(seen) {
6148
+ if (!seen || typeof seen !== 'object' || !Array.isArray(seen.sheets) || seen.sheets.length > 512) return null;
6149
+ const sheets = seen.sheets.filter((s) => s && FLO_HASH.test(s.sourceHash) && Number.isSafeInteger(s.pageNumber) && s.pageNumber >= 1);
6150
+ if (sheets.length !== seen.sheets.length) return null;
6151
+ return { sheets, whole: seen.sinceStart === true && seen.complete === true };
6152
+ }
6153
+
6023
6154
  /**
6024
6155
  * #2926: what the Drawing Filter's Flo shows for the read the progress strip speaks for, from that read's own
6025
6156
  * signals only. `reading` while it is evidently working (with the sheet pictures it last asked for), `waiting`
@@ -6062,27 +6193,30 @@
6062
6193
  return { mode: 'waiting', text, chat: inChat };
6063
6194
  }
6064
6195
  const looks = (Array.isArray(req.steelLooks) ? req.steelLooks : []).filter(floLookOk);
6196
+ // #3093: the strip shows the AI's own sentence right above the stage, so Flo never repeats it. It says where it is,
6197
+ // from the looks, and how many sheets it has looked at; `note` is only for a sentence the strip does not show.
6198
+ const reading = (extra) => ({ mode: 'reading', looks, seen: floSeenOk(req.steelSeen), ...extra });
6065
6199
  const freshPictures = looks.some((l) => l.ageMs < (busy ? FLO_BUSY_LOOK_MS : FLO_FRESH_WORK_MS));
6066
6200
  // Seen on a real read in AI Chat (2026-11-01): the AI fetched S-201 tile by tile before it wrote its first
6067
6201
  // progress record, and Flo stayed hidden while it read. Its pictures prove the work; the words say what is unknown.
6068
6202
  // The same after Save: the record still says "waiting for you to press Save filter" (a wait the conversation has
6069
6203
  // moved past, above) until the AI next writes it.
6070
6204
  if (!view || raw === 'waiting') {
6071
- return freshPictures ? { mode: 'reading', now: 'The AI is looking at the drawings. Its progress list has not caught up yet.', looks }
6205
+ return freshPictures ? reading({ note: 'Its progress list has not caught up yet.' })
6072
6206
  : off(view ? 'not-active' : 'no-record');
6073
6207
  }
6074
6208
  if (raw !== 'active') return off('not-active');
6075
6209
  // A record the AI has not rewritten for 8 minutes is stale, but pictures it asked for in the last two, or its
6076
6210
  // conversation still running, prove it is still at work (seen on a real read, #2926: tiles seconds old, sentence
6077
- // 9 minutes old). Flo keeps going then, and says the sentence is the last one reported, the strip's own words.
6211
+ // 9 minutes old). Flo keeps going then; the strip itself says its sentence is the last one reported.
6078
6212
  if (view.state !== 'active') {
6079
- return freshPictures || chatWorking ? { mode: 'reading', now: view.now, looks, label: `${view.nowLabel}:` } : off('not-active');
6213
+ return freshPictures || chatWorking ? reading({}) : off('not-active');
6080
6214
  }
6081
6215
  // Pictures for this very read are proof of work even when the chat calls its turn busy elsewhere, which it
6082
6216
  // does whenever the person typed into the read's conversation and the read carried on.
6083
6217
  const working = freshPictures || !inChat || chatWorking;
6084
6218
  if (!working) return off('idle');
6085
- return view.fromChat ? { mode: 'reading', now: view.now, looks, label: `${view.nowLabel}:` } : { mode: 'reading', now: view.now, looks };
6219
+ return reading({});
6086
6220
  }
6087
6221
 
6088
6222
  // Keeps the last read and view applyStageGating() painted (`syncFilterFlo.last`), so a chat question opening
@@ -6713,7 +6847,7 @@
6713
6847
  if (typeof syncHistoryViews === 'function' && typeof currentStep !== 'undefined') {
6714
6848
  const activity = syncHistoryViews(currentStep, d);
6715
6849
  // A gate that appears under the open ledger moves the step to Activity (once: setStep leaves the panes matching).
6716
- if (currentStep === 'history' && activity && !$wsHistory.hidden) setStep('history');
6850
+ if (currentStep === 'history' && activity && !$wsHistory.hidden) (typeof redirectStep === 'function' ? redirectStep : setStep)('history');
6717
6851
  }
6718
6852
  if (!d || !d.filter) {
6719
6853
  // The tab strip is shared across projects. Remove every steel-only gate when switching to an
@@ -6759,7 +6893,7 @@
6759
6893
  // A project opened on the old default Model step can become gated when the lifecycle probe
6760
6894
  // returns. Move it to the first actionable stage instead of leaving a locked tab selected.
6761
6895
  if (currentStep !== 'drawings' && stageGateFor(currentStep)) {
6762
- setStep('drawings');
6896
+ (typeof redirectStep === 'function' ? redirectStep : setStep)('drawings');
6763
6897
  return;
6764
6898
  }
6765
6899
  // The strip always speaks for a save waiting on the person (confirm), refused (blocked) or needing a
@@ -6883,30 +7017,31 @@
6883
7017
  const d = wsApp();
6884
7018
  if (!current || !d?.filter || projectContractLifecycle !== 'unknown'
6885
7019
  || !['model', 'rfis', 'exports', 'history'].includes(s)) return false;
6886
- pendingPresenceStep = { projectId: current.id, step: s };
7020
+ // FloLess's own redirect (redirectStep) only repaints the step the person is on; it must not replace their click.
7021
+ if (typeof stepRedirecting !== 'undefined' && stepRedirecting) return false;
7022
+ pendingPresenceStep = { projectId: current.id, step: s, asked: true };
6887
7023
  const projectId = current.id;
6888
7024
  if (pendingPresenceToast) pendingPresenceToast();
6889
- const intentToast = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info');
7025
+ // Persistent while the check runs (#3139): it retries by itself for up to its budget, so the promise stays on
7026
+ // screen until the answer opens the step. Past a few seconds it says the wait is longer than usual, swapped in
7027
+ // place so the toast does not flicker.
7028
+ let dismissShown = showToast(`Checking project stages… ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
7029
+ let slowTimer = null;
7030
+ const intentToast = () => { clearTimeout(slowTimer); dismissShown(); };
7031
+ slowTimer = setTimeout(() => {
7032
+ if (pendingPresenceToast !== intentToast) return;
7033
+ dismissShown(true);
7034
+ dismissShown = showToast(`Still checking project stages. This is taking longer than usual. ${stepLabel(s)} will open when ready.`, 'info', { persistent: true });
7035
+ }, 6000);
6890
7036
  pendingPresenceToast = intentToast;
6891
- refreshModelPresence(projectId, current.app).then(() => {
7037
+ // Whichever check applies an answer settles this click (settleAskedStep, from applyModelPresence): this one, or an
7038
+ // Exports or History render's that overtook it. Until then the step stays held and its toast stays up.
7039
+ refreshModelPresence(projectId, current.app).catch((err) => {
6892
7040
  // A later click owns the shared probe's feedback and destination.
6893
- if (pendingPresenceToast !== intentToast) return;
6894
- intentToast();
6895
- pendingPresenceToast = null;
6896
- // The request's four-second deadline is a recovery boundary, not a silent discarded click.
6897
- if (current?.id !== projectId) return;
6898
- if (projectContractLifecycle === 'unknown') {
6899
- showToast(`Couldn’t check project stages. Select ${stepLabel(s)} again to retry.`, 'warn');
6900
- return;
6901
- }
6902
- // A confirmed preliminary answer turns the apparent availability into the real prerequisite
6903
- // gate. Reuse that specific explanation instead of replacing it with generic readiness copy.
6904
- const reason = stageGateFor(s);
6905
- if (reason) showToast(reason, 'warn');
6906
- }).catch((err) => {
6907
7041
  if (pendingPresenceToast === intentToast) {
6908
7042
  intentToast();
6909
7043
  pendingPresenceToast = null;
7044
+ if (pendingPresenceStep?.asked && pendingPresenceStep.projectId === projectId) pendingPresenceStep = null;
6910
7045
  }
6911
7046
  console.error('[workspaces] tab lifecycle check failed', err);
6912
7047
  });
@@ -6989,6 +7124,7 @@
6989
7124
  // the model boundary speculatively. The existing request is reused and this destination opens
6990
7125
  // automatically if it reports a model; the most recent click wins.
6991
7126
  if (deferStageUntilLifecycle(s)) return;
7127
+ if (typeof dropAskedStep === 'function') dropAskedStep();
6992
7128
  const lockedReason = stageGateFor(s);
6993
7129
  if (lockedReason) {
6994
7130
  if (currentStep !== 'drawings') setStep('drawings');
@@ -7494,7 +7630,8 @@
7494
7630
  const APPROVAL_REASON_CODES = ['tekla-approval-refused', 'grant-unavailable', 'approval-nothing-exportable', ...IMPORT_FINDINGS_REFUSAL_CODES];
7495
7631
  function knownApprovalFailureReason(error) {
7496
7632
  const body = error && error.body;
7497
- if (!body || typeof body.error !== 'string' || !body.error.trim()) return '';
7633
+ // #3097: a `diagnostic` reply's `error` is what was thrown, not a sentence for the person, whatever its code.
7634
+ if (!body || body.diagnostic || typeof body.error !== 'string' || !body.error.trim()) return '';
7498
7635
  return APPROVAL_REASON_CODES.includes(body.code) ? body.error.trim() : '';
7499
7636
  }
7500
7637
  /** The raw error, for the Technical details disclosure only: never the headline of a notice. */
@@ -7837,6 +7974,24 @@
7837
7974
  return `<span class="quick-pill${q.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + q.short)}</span>${spoken}`;
7838
7975
  }
7839
7976
 
7977
+ /**
7978
+ * #2554 slice 2: which drawing files a model did NOT read, beside its Quick label and never inside it (a fully
7979
+ * reviewed precise model can still be part of its set). Neutral, because the amber is the Quick label's; dashed when
7980
+ * FloLess could not tell. A model that read its whole set shows none. `besides` is the Quick label of the same
7981
+ * document: when FloLess could not read that document at all, its dashed Quick pill already says so, and a second
7982
+ * dashed pill naming no file would add nothing.
7983
+ */
7984
+ function coveragePillHtml(c, opts = {}) {
7985
+ if (!c || (c.state !== 'part' && c.state !== 'unknown') || typeof c.short !== 'string' || !c.short) return '';
7986
+ if (opts.besides && opts.besides.state === 'unknown' && c.state === 'unknown' && !c.count && quickPillHtml(opts.besides)) return '';
7987
+ const scope = opts.scope ? `${opts.scope}: ` : '';
7988
+ const tip = `${scope}${c.text || c.short}`;
7989
+ const nested = opts.focusable === false;
7990
+ const carrier = nested ? '' : ' data-command-id="shell.read-coverage-note" tabindex="0"';
7991
+ const spoken = nested ? `<span class="sr-only"> (${escapeHtml(tip)})</span>` : '';
7992
+ return `<span class="coverage-pill${c.state === 'unknown' ? ' is-unknown' : ''}"${carrier} data-tip="${escapeAttr(tip)}">${escapeHtml((opts.showScope ? scope : '') + c.short)}</span>${spoken}`;
7993
+ }
7994
+
7840
7995
  /**
7841
7996
  * The header chip: ONE compact chip for the approved head and, whenever it differs from the head, the working copy.
7842
7997
  * Its tooltip names each document and says what it rests on, so the header never grows a second chip that pushes
@@ -7851,14 +8006,33 @@
7851
8006
  const parts = [];
7852
8007
  if (q && s.headVersion && quickPillHtml(q.head)) parts.push([`v${s.headVersion}`, q.head]);
7853
8008
  if (q && (s.pendingCount > 0 || !s.headVersion) && quickPillHtml(q.draft)) parts.push(['Working copy', q.draft]);
8009
+ // #2554 slice 2: which drawing files each document did not read, scoped the same way, folded into the same chip.
8010
+ const c = s.status === 'ready' && s.review && s.review.coverage ? s.review.coverage : null;
8011
+ const covered = [];
8012
+ if (c && s.headVersion && coveragePillHtml(c.head, { besides: q && q.head })) covered.push([`v${s.headVersion}`, c.head]);
8013
+ if (c && (s.pendingCount > 0 || !s.headVersion) && coveragePillHtml(c.draft, { besides: q && q.draft })) covered.push(['Working copy', c.draft]);
8014
+ const coverageTip = covered.map(([scope, note]) => `${scope}: ${note.text || note.short}`).join(' ');
8015
+ const coverageShort = covered.some(([, note]) => note.state === 'part') ? 'Part of the set' : 'Part of the set?';
8016
+ if (!parts.length && covered.length) {
8017
+ $quick.innerHTML = `<span class="coverage-pill${covered.every(([, note]) => note.state === 'unknown') ? ' is-unknown' : ''}" data-command-id="shell.read-coverage-note" tabindex="0" data-tip="${escapeAttr(coverageTip)}">${escapeHtml(coverageShort)}</span>`;
8018
+ $quick.hidden = false;
8019
+ return;
8020
+ }
7854
8021
  if (!parts.length) { $quick.innerHTML = ''; $quick.hidden = true; return; }
7855
8022
  // "Quick model" when any document it speaks for is readably Quick; "Possibly Quick model" when none is; dashed
7856
8023
  // whenever one of them could not be read.
7857
8024
  const anyQuick = parts.some(([, label]) => label.state === 'quick');
7858
8025
  const anyUnknown = parts.some(([, label]) => label.state === 'unknown');
8026
+ // The Quick document's explanation, then why each unreadable one could not be read (#2673); with two, each names
8027
+ // the document it explains, so a busy working copy is never read as a damaged version.
8028
+ const quickPart = parts.find(([, label]) => label.state === 'quick');
8029
+ const explained = [...(quickPart ? [quickPart] : []), ...parts.filter(([, label]) => label.state === 'unknown')]
8030
+ .filter(([, label]) => label.tip);
7859
8031
  const tip = parts.map(([scope, label]) => `${scope}: ${label.label}.`).join(' ')
7860
- + ` ${(parts.find(([, label]) => label.state === 'quick') || parts[0])[1].tip || ''}`;
7861
- $quick.innerHTML = `<span class="quick-pill${anyUnknown ? ' is-unknown' : ''}" data-command-id="shell.quick-model-label" tabindex="0" data-tip="${escapeAttr(tip.trim())}">${escapeHtml(anyQuick ? 'Quick model' : 'Possibly Quick model')}</span>`;
8032
+ + ` ${explained.map(([scope, label]) => (explained.length > 1 ? `${scope}: ${label.tip}` : label.tip)).join(' ')}`;
8033
+ const suffix = covered.length ? ` · ${coverageShort}` : '';
8034
+ const fullTip = covered.length ? `${tip.trim()} ${coverageTip}` : tip.trim();
8035
+ $quick.innerHTML = `<span class="quick-pill${anyUnknown ? ' is-unknown' : ''}" data-command-id="shell.quick-model-label" tabindex="0" data-tip="${escapeAttr(fullTip)}">${escapeHtml((anyQuick ? 'Quick model' : 'Possibly Quick model') + suffix)}</span>`;
7862
8036
  $quick.hidden = false;
7863
8037
  }
7864
8038
 
@@ -7874,7 +8048,7 @@
7874
8048
  const ownsDialog = () => !!dialog && approvalDialogState === dialog && onProject();
7875
8049
  if (ownsDialog() && $approvalRevisionNoteText) $approvalRevisionNoteText.value = '';
7876
8050
  if (res && res.approvedAt) project.approvedAt = res.approvedAt;
7877
- const { version: n, accepted, headline, assumed, quick } = approvalOutcomeWords(res);
8051
+ const { version: n, accepted, headline, assumed, quick, coverage } = approvalOutcomeWords(res);
7878
8052
  if (n) expandDiffOnce = { projectId: project.id, n };
7879
8053
  // An outcome can land while the person is editing this project again: a background check, or a dialog
7880
8054
  // closed while the note above was saving. Reloading the editor then would discard edits not yet saved, so
@@ -7904,7 +8078,7 @@
7904
8078
  // Edits still unsaved in the editor are not in any count FloLess read, so with them on screen no pending
7905
8079
  // count is claimed at all: the sentence says what is known instead.
7906
8080
  const keptEditsNote = 'Your newer edits stay in the editor and were not reloaded; once they are saved, reopen the model to see the approved version and what is still pending.';
7907
- showToast(`${headline} ${quick}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
8081
+ showToast(`${headline} ${quick}${coverage}${assumed ? `${assumed} ` : ''}${keptEdits ? keptEditsNote : pending === null ? pendingUnknown : pending ? `${pending} change${pending === 1 ? ' remains' : 's remain'} pending${saved ? ' in Saved work' : ''}; approved exports omit them unless you explicitly choose DRAFT.` : 'No changes remain pending.'}`, 'ok');
7908
8082
  track('workspace_project_approved', { app: project.app });
7909
8083
  if (onProject() && !$wsExports.hidden) safeRenderExports('after approving this version');
7910
8084
  if (onProject() && !$wsHistory.hidden) await renderHistory();
@@ -7914,7 +8088,7 @@
7914
8088
  : 'No changes remain pending.';
7915
8089
  // The footer described the decision ("…will be approved…"); the decision has happened.
7916
8090
  $approvalCounts.textContent = '';
7917
- $approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${quick ? `${escapeHtml(quick)}` : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
8091
+ $approvalBody.innerHTML = `<div class="approval-notice approval-notice-success"><b>${escapeHtml(headline)}</b> ${quick ? `${escapeHtml(quick)}` : ''}${coverage ? escapeHtml(coverage) : ''}The approved model and compiled workflow are ready.${assumed ? ' ' + escapeHtml(assumed) : ''}${revisionNoteStatus ? ' ' + escapeHtml(revisionNoteStatus) : ''}${accepted ? ' The findings stay listed in the Audit tab.' : ''}</div>`;
7918
8092
  setApprovalPhase('approved', accepted ? headline : `Approved${n ? ` as v${n}` : ''}`);
7919
8093
  $approvalClose.focus();
7920
8094
  }
@@ -7936,7 +8110,16 @@
7936
8110
  // #2521 row 5: an approved Quick model says so in the same breath, read from the approved version itself.
7937
8111
  const quick = res && res.quick && (res.quick.state === 'quick' || res.quick.state === 'unknown') && typeof res.quick.label === 'string'
7938
8112
  ? `${res.quick.label}. ` : '';
7939
- return { version, accepted, headline, assumed, quick, sentence: `${headline} ${quick}${assumed}`.trim() };
8113
+ // #2554 slice 2: and when it left drawing files unread, what that means for the approval and what covers them.
8114
+ // Unknown is never announced as a partial approval: it says FloLess could not tell. And when the version itself could
8115
+ // not be read (its Quick label is unknown too, with no file known unread) it is folded into that label, as the pills are.
8116
+ const c = res && res.coverage;
8117
+ const folded = c && c.state === 'unknown' && !c.count && res.quick && res.quick.state === 'unknown';
8118
+ const coverage = !c || folded || typeof c.brief !== 'string' ? ''
8119
+ : c.state === 'part' ? `${c.brief} This approval covers only the drawing files that were read; a later read of the others covers them. `
8120
+ : c.state === 'unknown' ? `${c.brief} FloLess could not tell whether this version read every drawing file; History shows what is known. `
8121
+ : '';
8122
+ return { version, accepted, headline, assumed, quick, coverage, sentence: `${headline} ${quick}${coverage}${assumed}`.trim() };
7940
8123
  }
7941
8124
 
7942
8125
  // One receipt read. The server answers under the project's approval locks, which on a large model
@@ -8731,6 +8914,7 @@
8731
8914
  let viewEpoch = 0; // invalidates in-flight preview loads
8732
8915
  let knowledgeRenderEpoch = 0; // invalidates in-flight /status loads (poll ticks race verbs)
8733
8916
  let kbTextAbort = null; // AbortController for the in-flight preview fetch
8917
+ let kbPdfView = null; // #3018: FloLess's own PDF viewer on the open preview — its worker is released with it
8734
8918
  let lastRefsHtml = null; // exact rendered HTML of the refs host, or null to force a repaint
8735
8919
  /* The graph's index page, stashed when the graph loads. The step header carries the ✦ Overview
8736
8920
  button, and the header is painted from knowledgeState — which does NOT hold the graph, because
@@ -8795,6 +8979,13 @@
8795
8979
  function kbAbortPreview() {
8796
8980
  viewEpoch += 1;
8797
8981
  if (kbTextAbort) { try { kbTextAbort.abort(); } catch { /* already settled */ } kbTextAbort = null; }
8982
+ kbReleasePdf();
8983
+ }
8984
+
8985
+ /** #3018: close the PDF viewer on the preview, if one is open, before anything replaces it. Its pdf.js worker, page
8986
+ * pictures and download link live outside the DOM, so emptying the host alone would leave them behind. */
8987
+ function kbReleasePdf() {
8988
+ if (kbPdfView) { kbPdfView.destroy(); kbPdfView = null; }
8798
8989
  }
8799
8990
 
8800
8991
  /** THE one place `viewer` changes. Detaches native `src` (an already-started iframe/image load
@@ -10118,6 +10309,7 @@
10118
10309
  }
10119
10310
 
10120
10311
  const kbPaintView = (row, bodyHtml) => {
10312
+ kbReleasePdf();
10121
10313
  const host = kbViewHost();
10122
10314
  if (host) host.innerHTML = kbViewShell(row, bodyHtml);
10123
10315
  };
@@ -10191,7 +10383,7 @@
10191
10383
  return;
10192
10384
  }
10193
10385
 
10194
- if (row.mime === 'application/pdf') kbPaintPdf(row, url);
10386
+ if (row.mime === 'application/pdf') await kbPaintPdf(proj, row, url, ac, alive);
10195
10387
  else if (row.mime === 'image/png' || row.mime === 'image/jpeg' || row.mime === 'image/webp') kbPaintImage(row, url, alive);
10196
10388
  else kbPaintText(row, url, ac, alive);
10197
10389
  }
@@ -10551,12 +10743,34 @@
10551
10743
  kbPaintNoPreview(fresh, fresh.kind === 'file' ? 'missing' : 'nofile');
10552
10744
  }
10553
10745
 
10554
- function kbPaintPdf(row, url) {
10555
- const name = row.filename || 'untitled';
10556
- // The iframe `title` is the ONE native title= the codebase allows (it is the accessible name);
10557
- // verify-no-title.mjs only exempts it when `<iframe` and `title=` sit on the SAME source line.
10558
- kbPaintView(row,
10559
- `<iframe class="kb-view-pdf" src="${escapeAttr(url)}" title="${escapeAttr(name)}"></iframe>`);
10746
+ /** #3018: a PDF is drawn by FloLess's own viewer (web/pdf-view.js), never the browser's in an <iframe>, whose light
10747
+ * scrollbar and random-id title FloLess's CSS cannot reach. It reads the file ONCE and draws exactly those bytes; the
10748
+ * HEAD before it proves nothing about this GET, so this answer is checked on its own (a 404 is the missing path). */
10749
+ async function kbPaintPdf(proj, row, url, ac, alive) {
10750
+ kbPaintView(row, kbViewLoading(row));
10751
+ let data;
10752
+ try {
10753
+ const res = await fetch(url, { signal: ac.signal, cache: 'no-store' });
10754
+ if (!alive()) { await res.body?.cancel().catch(() => {}); return; }
10755
+ if (res.status === 404) { await kbHandleMissing(proj, row, alive); return; }
10756
+ if (!res.ok) {
10757
+ kbPaintError(row, res.status === 402
10758
+ ? 'Your session needs refreshing — sign in again and retry.'
10759
+ : 'The server hit an error trying to read it.');
10760
+ return;
10761
+ }
10762
+ data = new Uint8Array(await res.arrayBuffer());
10763
+ } catch (err) {
10764
+ if (err && err.name === 'AbortError') return; // superseded — never paint
10765
+ if (alive()) kbPaintError(row, 'Lost the connection while loading it.');
10766
+ return;
10767
+ }
10768
+ if (!alive()) return;
10769
+ kbPaintView(row, '');
10770
+ const body = kbViewHost()?.querySelector('.kb-view-body');
10771
+ if (!body) return;
10772
+ // The header above already names the file, so the viewer's toolbar does not say it twice.
10773
+ kbPdfView = window.flolessPdfView.mount(body, { bytes: data, name: row.filename || 'untitled.pdf', showName: false });
10560
10774
  }
10561
10775
 
10562
10776
  /** A 200 does NOT imply a decodable image: sniffMime matches a 3-byte JPEG (FF D8 FF) and the upload
@@ -10891,6 +11105,7 @@
10891
11105
  if ($wsKnowledge.querySelector('.kb-split')) return;
10892
11106
  // The rail and the stub are SIBLINGS of .kb-refs-host, never children of it: the host's innerHTML
10893
11107
  // is replaced wholesale on every poll repaint, so anything inside it is destroyed 3 s later.
11108
+ kbReleasePdf();
10894
11109
  $wsKnowledge.innerHTML = kbStepHeadHtml(knowledgeState) +
10895
11110
  '<div class="kb-split">' +
10896
11111
  '<div class="kb-refs-host" id="kb-refs-host"></div>' +
@@ -11145,8 +11360,10 @@
11145
11360
  catch (err) {
11146
11361
  if (stale()) return;
11147
11362
  stopKnowledgePoll();
11363
+ // #3097: what could not be done, why and what to do, from the shared copy; the error itself is for the console.
11364
+ console.warn('[workspaces] the knowledge base could not be loaded', err);
11148
11365
  kbPaintRefsMessage(
11149
- `<div class="kb-empty">Couldn’t load the knowledge base: ${escapeHtml(String((err && err.message) || err))}</div>`);
11366
+ `<div class="kb-empty">${escapeHtml(failureCopy(err, { action: 'load the knowledge base', retrySafe: true }).text)}</div>`);
11150
11367
  return;
11151
11368
  }
11152
11369
  if (stale()) return; // switched project/step — or opened a confirm — during the fetch
@@ -11157,6 +11374,54 @@
11157
11374
  // One modal extends the existing Knowledge surface. Shared entries are immutable versions;
11158
11375
  // nothing reaches this project's source list until the user explicitly accepts one.
11159
11376
  let companyKnowledgeProjectId = null;
11377
+ // #3151: bumped on every open and close, so a request that outlives the dialog it started in
11378
+ // (the project changed under it) can tell, and drops its result instead of writing into the next one.
11379
+ let companyKnowledgeSession = 0;
11380
+ const COMPANY_KNOWLEDGE_BUSY_REASON = 'FloLess is still saving this change. You can close this window when it finishes.';
11381
+
11382
+ function companySetStatus(message) {
11383
+ if (!$companyKnowledgeStatus) return;
11384
+ $companyKnowledgeStatus.hidden = !message;
11385
+ $companyKnowledgeStatus.textContent = message || '';
11386
+ }
11387
+
11388
+ /** Close, ×, Back and the dismiss gestures wait while a change is in flight; the action button is render's. */
11389
+ function syncCompanyKnowledgeBusy() {
11390
+ for (const button of [$companyKnowledgeClose, $companyKnowledgeCancel]) {
11391
+ if (!button) continue;
11392
+ button.disabled = companyKnowledgeBusy;
11393
+ if (companyKnowledgeBusy) button.dataset.blockedReason = COMPANY_KNOWLEDGE_BUSY_REASON;
11394
+ else delete button.dataset.blockedReason;
11395
+ }
11396
+ $companyKnowledgeClose.dataset.tip = companyKnowledgeBusy ? COMPANY_KNOWLEDGE_BUSY_REASON : 'Close';
11397
+ $companyKnowledgeDialog.setAttribute('aria-busy', String(companyKnowledgeBusy));
11398
+ // A disabled button drops focus to the page; keep it in the dialog so Escape and Tab still land here.
11399
+ if (companyKnowledgeBusy && document.activeElement?.disabled && $companyKnowledgeModal.contains(document.activeElement)) {
11400
+ $companyKnowledgeDialog.focus({ preventScroll: true });
11401
+ }
11402
+ if (!companyKnowledgeBusy) companySetStatus('');
11403
+ }
11404
+
11405
+ /** A request from an earlier opening has settled after the dialog reopened (for another project): the
11406
+ * new dialog was painted busy and loaded before that change landed, so repaint it from a fresh read. */
11407
+ async function companyRefreshAfterStale() {
11408
+ if (!$companyKnowledgeModal.classList.contains('show') || !companyKnowledgeProjectId) { syncCompanyKnowledgeBusy(); return; }
11409
+ const session = companyKnowledgeSession;
11410
+ // Stay busy through the re-read, so an action started in the new dialog waits for it and its own
11411
+ // result can never be overwritten by this older read landing after it.
11412
+ companyKnowledgeBusy = true;
11413
+ try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); } catch { /* the open dialog keeps what it loaded */ }
11414
+ finally {
11415
+ companyKnowledgeBusy = false;
11416
+ if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
11417
+ }
11418
+ }
11419
+
11420
+ /** Every person-driven way out of the dialog: blocked, with the reason said, while a change runs. */
11421
+ function dismissCompanyKnowledge() {
11422
+ if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
11423
+ closeCompanyKnowledge();
11424
+ }
11160
11425
 
11161
11426
  function companyVersionNumber(entry, versionId) {
11162
11427
  const at = entry && Array.isArray(entry.versions)
@@ -11279,21 +11544,28 @@
11279
11544
  async function companyCatPost(path, body, okMsg) {
11280
11545
  const state = companyKnowledgeState;
11281
11546
  if (companyKnowledgeBusy || !state || !state.available) return null;
11282
- companyKnowledgeBusy = true; companySetError('');
11547
+ const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
11548
+ companyKnowledgeBusy = true; companySetError(''); syncCompanyKnowledgeBusy();
11283
11549
  try {
11284
11550
  const res = await api(path, { method: 'POST', body: JSON.stringify({ expected: companyCatExpected(state), ...body }) });
11285
- companyCatEdit = null;
11551
+ // Company categories are company-wide, so the toast is true whichever project is on screen now.
11286
11552
  if (okMsg) showToast(okMsg, 'ok');
11553
+ if (session !== companyKnowledgeSession) return null;
11554
+ companyCatEdit = null;
11287
11555
  return res;
11288
11556
  } catch (error) {
11289
- const said = error && error.body && typeof error.body.error === 'string' && /^[A-Z]/.test(error.body.error) ? error.body.error : '';
11290
- companySetError(said || 'FloLess could not change the company categories just now. Try again.');
11557
+ const said = /^[A-Z]/.test(personText(error && error.body)) ? personText(error && error.body) : '';
11558
+ const message = said || 'FloLess could not change the company categories just now. Try again.';
11559
+ if (session !== companyKnowledgeSession) { showToast(message, 'warn'); return null; }
11560
+ companySetError(message);
11291
11561
  if (body.expected && error && error.body && error.body.code === 'knowledge-categories-changed') companyCatEdit = null;
11292
11562
  return null;
11293
11563
  } finally {
11294
11564
  companyKnowledgeBusy = false;
11295
- try { await loadCompanyKnowledge(companyKnowledgeProjectId); } catch { /* the error line says what happened */ }
11296
- renderCompanyKnowledge();
11565
+ if (session === companyKnowledgeSession) {
11566
+ try { await loadCompanyKnowledge(projectId); } catch { /* the error line says what happened */ }
11567
+ }
11568
+ if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale();
11297
11569
  }
11298
11570
  }
11299
11571
  /** What a company category change is checked against: the categories' revision and the company folder. */
@@ -11478,44 +11750,56 @@
11478
11750
  $companyKnowledgeAction.disabled = companyKnowledgeBusy || !available;
11479
11751
  if (!available) $companyKnowledgeAction.dataset.blockedReason = 'Choose an available company folder first';
11480
11752
  else delete $companyKnowledgeAction.dataset.blockedReason;
11481
- $companyKnowledgeDialog.setAttribute('aria-busy', String(companyKnowledgeBusy));
11753
+ syncCompanyKnowledgeBusy();
11482
11754
  }
11483
11755
 
11484
- async function loadCompanyKnowledge(projectId) {
11485
- companyKnowledgeState = await api(`/api/company-knowledge?projectId=${encodeURIComponent(projectId)}`);
11486
- return companyKnowledgeState;
11756
+ async function loadCompanyKnowledge(projectId, session = companyKnowledgeSession) {
11757
+ const state = await api(`/api/company-knowledge?projectId=${encodeURIComponent(projectId)}`);
11758
+ // A read that finishes after its dialog closed belongs to no screen; never let it overwrite the next one.
11759
+ if (session === companyKnowledgeSession) companyKnowledgeState = state;
11760
+ return state;
11487
11761
  }
11488
11762
 
11489
11763
  async function openCompanyKnowledge(promotion, returnFocus) {
11490
11764
  if (!current || !$companyKnowledgeModal) return;
11765
+ const session = ++companyKnowledgeSession;
11491
11766
  companyKnowledgeProjectId = current.id;
11492
11767
  companyKnowledgePromotion = promotion || null;
11493
11768
  companyKnowledgePending = null;
11494
11769
  companyKnowledgeReturnFocus = returnFocus || document.activeElement;
11495
- companySetError('');
11770
+ companySetError(''); companySetStatus('');
11496
11771
  $companyKnowledgeModal.classList.add('show');
11497
11772
  $companyKnowledgeFolder.innerHTML = '<div class="company-empty">Loading company knowledge…</div>';
11498
11773
  $companyKnowledgeList.innerHTML = '';
11499
- $companyKnowledgeClose.focus({ preventScroll: true });
11500
- try { await loadCompanyKnowledge(companyKnowledgeProjectId); }
11501
- catch (error) { companyKnowledgeState = { configured: false, loadError: companyErrorMessage(error, 'FloLess could not load company references. Check the company folder and try again.') }; }
11502
- if ($companyKnowledgeModal.classList.contains('show')) renderCompanyKnowledge();
11774
+ // An earlier opening's change may still be running, which leaves Close disabled; focus the dialog then.
11775
+ ($companyKnowledgeClose.disabled ? $companyKnowledgeDialog : $companyKnowledgeClose).focus({ preventScroll: true });
11776
+ try { await loadCompanyKnowledge(companyKnowledgeProjectId, session); }
11777
+ catch (error) {
11778
+ if (session !== companyKnowledgeSession) return;
11779
+ companyKnowledgeState = { configured: false, loadError: companyErrorMessage(error, 'FloLess could not load company references. Check the company folder and try again.') };
11780
+ }
11781
+ if (session === companyKnowledgeSession) renderCompanyKnowledge();
11503
11782
  }
11504
11783
 
11505
11784
  function closeCompanyKnowledge(restoreFocus = true) {
11506
11785
  if (!$companyKnowledgeModal || !$companyKnowledgeModal.classList.contains('show')) return;
11507
11786
  $companyKnowledgeModal.classList.remove('show');
11787
+ companyKnowledgeSession += 1;
11508
11788
  const back = companyKnowledgeReturnFocus;
11509
11789
  companyKnowledgeReturnFocus = null;
11510
11790
  companyKnowledgePromotion = null;
11511
11791
  companyKnowledgePending = null;
11512
11792
  companyKnowledgeProjectId = null;
11513
- companySetError('');
11514
- if (restoreFocus && back && back.isConnected) back.focus({ preventScroll: true });
11793
+ companySetError(''); companySetStatus('');
11794
+ // The Knowledge header repaints while the dialog is open (an Add, the status poll), replacing the
11795
+ // button that opened it; return focus to the one on screen now rather than dropping it on the page.
11796
+ const target = back && back.isConnected ? back : document.querySelector('[data-company-open]');
11797
+ if (restoreFocus && target) target.focus({ preventScroll: true });
11515
11798
  }
11516
11799
 
11517
11800
  async function chooseCompanyFolder() {
11518
11801
  if (companyKnowledgeBusy) return;
11802
+ const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
11519
11803
  companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
11520
11804
  try {
11521
11805
  const choice = await api('/api/company-knowledge/folder/choose', { method: 'POST', body: '{}' });
@@ -11523,17 +11807,27 @@
11523
11807
  await api('/api/company-knowledge/folder/select', {
11524
11808
  method: 'POST', body: JSON.stringify({ selectionId: choice.selectionId }),
11525
11809
  });
11526
- await loadCompanyKnowledge(companyKnowledgeProjectId);
11810
+ // The folder is machine-wide: it is connected whichever project is on screen by now.
11527
11811
  showToast('Company knowledge folder connected', 'ok');
11812
+ if (session === companyKnowledgeSession) await loadCompanyKnowledge(projectId, session);
11528
11813
  }
11529
- } catch (error) { companySetError(companyErrorMessage(error, 'FloLess could not use that company folder. Choose another folder and try again.')); }
11530
- finally { companyKnowledgeBusy = false; renderCompanyKnowledge(); }
11814
+ } catch (error) {
11815
+ const message = companyErrorMessage(error, 'FloLess could not use that company folder. Choose another folder and try again.');
11816
+ if (session === companyKnowledgeSession) companySetError(message); else showToast(message, 'warn');
11817
+ }
11818
+ finally { companyKnowledgeBusy = false; if (session === companyKnowledgeSession) renderCompanyKnowledge(); else void companyRefreshAfterStale(); }
11531
11819
  }
11532
11820
 
11533
11821
  async function performCompanyKnowledgeAction() {
11534
11822
  if (companyKnowledgeBusy || !companyKnowledgeProjectId) return;
11535
11823
  const state = companyKnowledgeState;
11536
11824
  if (!state || !state.available) return;
11825
+ // #3151: the person cannot close the dialog while this runs, but a project switch still can. Every
11826
+ // await below re-checks the session: a stale result still tells the person what happened, but never
11827
+ // writes into the dialog that replaced it or reloads it with no project.
11828
+ const session = companyKnowledgeSession, projectId = companyKnowledgeProjectId;
11829
+ const projectName = current && current.id === projectId ? current.name : '';
11830
+ const stale = () => session !== companyKnowledgeSession;
11537
11831
  companyKnowledgeBusy = true; companySetError(''); renderCompanyKnowledge();
11538
11832
  try {
11539
11833
  if (companyKnowledgePending?.kind === 'accept') {
@@ -11541,8 +11835,10 @@
11541
11835
  const latest = entry && entry.versions[entry.versions.length - 1];
11542
11836
  if (!entry || !latest) throw new Error('That company version is no longer available.');
11543
11837
  const res = await api(`/api/company-knowledge/sources/${encodeURIComponent(entry.librarySourceId)}/versions/${encodeURIComponent(latest.versionId)}/accept`, {
11544
- method: 'POST', body: JSON.stringify({ projectId: companyKnowledgeProjectId }),
11838
+ method: 'POST', body: JSON.stringify({ projectId }),
11545
11839
  });
11840
+ // Another project is on screen by now: say which project it went to instead of "this project".
11841
+ if (stale()) { showToast(`Added ${entry.displayName} v${entry.versions.length} to ${projectName || 'the project you started it in'}.`, 'ok'); return; }
11546
11842
  companyKnowledgePending = null;
11547
11843
  // #2491 R6.9: where it went in this project's categories, and why.
11548
11844
  const placed = res && res.placement;
@@ -11550,24 +11846,30 @@
11550
11846
  } else if (companyKnowledgePending?.kind === 'remove') {
11551
11847
  const entry = state.sources.find((row) => row.librarySourceId === companyKnowledgePending.librarySourceId);
11552
11848
  await api(`/api/company-knowledge/sources/${encodeURIComponent(companyKnowledgePending.librarySourceId)}`, { method: 'DELETE' });
11553
- companyKnowledgePending = null;
11849
+ // Company-wide, so the toast is true whichever project is on screen now.
11554
11850
  showToast(`${entry ? entry.displayName : 'Company reference'} removed`, 'ok');
11851
+ if (stale()) return;
11852
+ companyKnowledgePending = null;
11555
11853
  } else if (companyKnowledgePromotion) {
11556
11854
  const promoted = await api('/api/company-knowledge/promote', {
11557
11855
  method: 'POST', body: JSON.stringify({
11558
- projectId: companyKnowledgeProjectId,
11856
+ projectId,
11559
11857
  sourceId: companyKnowledgePromotion.sourceId,
11560
11858
  librarySourceId: $companyPromotionLineage.value || null,
11561
11859
  }),
11562
11860
  });
11563
11861
  const placed = promoted && promoted.placement;
11564
11862
  showToast(`Company reference published${placed && placed.categoryId ? `, in ${placed.where}` : ''}.${placed && placed.note && !placed.categoryId ? ` ${placed.note}` : ''}`, placed && placed.note && !placed.categoryId ? 'warn' : 'ok');
11863
+ if (stale()) return;
11565
11864
  companyKnowledgePromotion = null;
11566
11865
  }
11567
- await loadCompanyKnowledge(companyKnowledgeProjectId);
11568
- if (current && current.id === companyKnowledgeProjectId) await renderKnowledge();
11569
- } catch (error) { companySetError(companyErrorMessage(error)); }
11570
- finally { companyKnowledgeBusy = false; renderCompanyKnowledge(); }
11866
+ await loadCompanyKnowledge(projectId, session);
11867
+ if (!stale() && current && current.id === projectId) await renderKnowledge();
11868
+ } catch (error) {
11869
+ // With its dialog gone, the toast is the only place left to say it.
11870
+ if (stale()) showToast(companyErrorMessage(error), 'warn'); else companySetError(companyErrorMessage(error));
11871
+ }
11872
+ finally { companyKnowledgeBusy = false; if (stale()) void companyRefreshAfterStale(); else renderCompanyKnowledge(); }
11571
11873
  }
11572
11874
 
11573
11875
  if ($companyKnowledgeModal) {
@@ -11580,13 +11882,14 @@
11580
11882
  const remove = event.target.closest('[data-company-stage-remove]');
11581
11883
  if (remove) { companyKnowledgePending = { kind: 'remove', librarySourceId: remove.dataset.companyStageRemove }; renderCompanyKnowledge(); $companyKnowledgeAction.focus(); }
11582
11884
  });
11583
- $companyKnowledgeClose.addEventListener('click', () => closeCompanyKnowledge());
11885
+ $companyKnowledgeClose.addEventListener('click', () => dismissCompanyKnowledge());
11584
11886
  $companyKnowledgeCancel.addEventListener('click', () => {
11887
+ if (companyKnowledgeBusy) { companySetStatus(COMPANY_KNOWLEDGE_BUSY_REASON); return; }
11585
11888
  if (companyKnowledgePending) { companyKnowledgePending = null; companySetError(''); renderCompanyKnowledge(); }
11586
11889
  else closeCompanyKnowledge();
11587
11890
  });
11588
11891
  $companyKnowledgeAction.addEventListener('click', performCompanyKnowledgeAction);
11589
- onBackdropDismiss($companyKnowledgeModal, () => closeCompanyKnowledge());
11892
+ onBackdropDismiss($companyKnowledgeModal, () => dismissCompanyKnowledge());
11590
11893
  document.addEventListener('keydown', (event) => {
11591
11894
  if (!$companyKnowledgeModal.classList.contains('show')) return;
11592
11895
  // #2491 R6.9: the name box and the menus answer their own keys first; Escape closes them, not the dialog.
@@ -11607,7 +11910,7 @@
11607
11910
  const at = items.indexOf(document.activeElement);
11608
11911
  if (at >= 0) { event.preventDefault(); items[(at + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length].focus(); return; }
11609
11912
  }
11610
- if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); closeCompanyKnowledge(); return; }
11913
+ if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); dismissCompanyKnowledge(); return; }
11611
11914
  if (event.key !== 'Tab') return;
11612
11915
  const focusable = [...$companyKnowledgeModal.querySelectorAll('button:not([hidden]):not(:disabled), input:not([hidden]):not(:disabled), [tabindex="0"]')]
11613
11916
  .filter((node) => node.offsetParent !== null);
@@ -11703,7 +12006,7 @@
11703
12006
  showToast(code === 'design-set-changed'
11704
12007
  ? 'The design set changed while this was open. Check it and choose again.'
11705
12008
  // The server's own sentence says what to do (busy, file not in the project, an index it cannot take).
11706
- : (err && err.body && typeof err.body.error === 'string' && err.body.error) || 'Couldn’t change the design set. Try again.', 'warn');
12009
+ : personText(err && err.body) || 'Couldn’t change the design set. Try again.', 'warn');
11707
12010
  }
11708
12011
  if (current !== proj) return;
11709
12012
  kbInvalidateRefs();
@@ -11960,7 +12263,7 @@
11960
12263
  function kbDsErrorText(err, fallback) {
11961
12264
  const code = err && err.body && err.body.code;
11962
12265
  if (code === 'design-set-changed') return 'The design set changed while this was open. Check it and try again.';
11963
- return (err && err.body && typeof err.body.error === 'string' && err.body.error) || fallback;
12266
+ return personText(err && err.body) || fallback;
11964
12267
  }
11965
12268
  function kbDsOpenPanel(panel, focus) {
11966
12269
  kbCloseConfirm();
@@ -13652,7 +13955,7 @@
13652
13955
  aborted.push(...hosts.slice(i));
13653
13956
  break;
13654
13957
  }
13655
- const detail = (err && err.body && err.body.error) || (err && err.message) || String(err);
13958
+ const detail = personText(err && err.body) || (err && err.message) || String(err);
13656
13959
  failed.push({ host, error: detail });
13657
13960
  }
13658
13961
  }
@@ -14369,17 +14672,17 @@
14369
14672
  // #2449: each approved source carries its own frozen connection-assumptions label from the server, bound to it.
14370
14673
  const frozen = (row) => (row && row.connectionAssumptions && typeof row.connectionAssumptions.note === 'string' ? row.connectionAssumptions : null);
14371
14674
  // #2521 row 5: `quick` first, so each option keeps the exact shape the #2449 checks read.
14372
- if (data.default) out.push({ quick: data.default.quick, selector: { kind: 'latest-approved' }, label: `Latest approved · v${data.default.version}`, group: 'Recommended', version: data.default.version, assumptions: frozen(data.default) });
14675
+ if (data.default) out.push({ quick: data.default.quick, coverage: data.default.coverage, selector: { kind: 'latest-approved' }, label: `Latest approved · v${data.default.version}`, group: 'Recommended', version: data.default.version, assumptions: frozen(data.default) });
14373
14676
  if (data.working) out.push({
14374
14677
  selector: {
14375
14678
  kind: 'working', expectedEtag: data.working.etag,
14376
14679
  ...(data.working.epoch !== null && Number.isInteger(Number(data.working.epoch)) ? { expectedEpoch: Number(data.working.epoch) } : {}),
14377
14680
  },
14378
- label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick,
14681
+ label: 'Working copy · DRAFT', group: 'Drafts', quick: data.working.quick, coverage: data.working.coverage,
14379
14682
  });
14380
- for (const saved of data.checkpoints || []) out.push({ selector: { kind: 'checkpoint', checkpointId: saved.checkpointId, expectedHash: saved.hash }, label: `Checkpoint ${String(saved.checkpointId).slice(0, 8)} · DRAFT`, group: 'Drafts', sub: saved.baseVersion ? `Pending work from v${saved.baseVersion}` : 'No approved baseline', quick: saved.quick });
14683
+ for (const saved of data.checkpoints || []) out.push({ selector: { kind: 'checkpoint', checkpointId: saved.checkpointId, expectedHash: saved.hash }, label: `Checkpoint ${String(saved.checkpointId).slice(0, 8)} · DRAFT`, group: 'Drafts', sub: saved.baseVersion ? `Pending work from v${saved.baseVersion}` : 'No approved baseline', quick: saved.quick, coverage: saved.coverage });
14381
14684
  for (const row of data.defaultUnavailable?.reason === 'refused' ? [] : (data.approved || [])) {
14382
- if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ quick: row.quick, selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history', version: row.version, assumptions: frozen(row) });
14685
+ if (!data.default || Number(row.version) !== Number(data.default.version)) out.push({ quick: row.quick, coverage: row.coverage, selector: { kind: 'approved', version: row.version }, label: `Older approved · v${row.version}`, group: 'Approved history', version: row.version, assumptions: frozen(row) });
14383
14686
  }
14384
14687
  return out;
14385
14688
  }
@@ -14421,7 +14724,7 @@
14421
14724
  const rows = options.filter((option) => option.group === group);
14422
14725
  if (!rows.length) return '';
14423
14726
  return `<div class="export-source-group" role="group" aria-label="${escapeAttr(group)}"><div class="export-source-group-label">${escapeHtml(group)}</div>`
14424
- + rows.map((option) => { const key = JSON.stringify(option.selector); const quickTip = quickPillHtml(option.quick) ? ` data-tip="${escapeAttr(`${option.label}: ${option.quick.label}. ${option.quick.tip || ''}`.trim())}"` : ''; return `<button type="button" class="export-source-option${key === selectedKey ? ' selected' : ''}" role="option" aria-selected="${String(key === selectedKey)}" data-export-source="${escapeAttr(key)}"${quickTip}><span>${escapeHtml(option.label)}${quickPillHtml(option.quick, { scope: option.label, focusable: false })}</span>${option.sub ? `<small>${escapeHtml(option.sub)}</small>` : ''}</button>`; }).join('') + '</div>';
14727
+ + rows.map((option) => { const key = JSON.stringify(option.selector); const covered = coveragePillHtml(option.coverage, { besides: option.quick }); const quickTip = quickPillHtml(option.quick) || covered ? ` data-tip="${escapeAttr(`${option.label}: ${quickPillHtml(option.quick) ? `${option.quick.label}. ${option.quick.tip || ''}` : ''}${covered ? ` ${option.coverage.text || option.coverage.short}` : ''}`.replace(/\s+/gu, ' ').trim())}"` : ''; return `<button type="button" class="export-source-option${key === selectedKey ? ' selected' : ''}" role="option" aria-selected="${String(key === selectedKey)}" data-export-source="${escapeAttr(key)}"${quickTip}><span>${escapeHtml(option.label)}${quickPillHtml(option.quick, { scope: option.label, focusable: false })}${coveragePillHtml(option.coverage, { scope: option.label, focusable: false, besides: option.quick })}</span>${option.sub ? `<small>${escapeHtml(option.sub)}</small>` : ''}</button>`; }).join('') + '</div>';
14425
14728
  }).join('');
14426
14729
  let warning = '';
14427
14730
  if (data.defaultUnavailable?.reason === 'refused') {
@@ -14458,15 +14761,22 @@
14458
14761
  const source = currentExportSourceOption();
14459
14762
  if (!source) return '';
14460
14763
  const line = (q, scope) => (quickPillHtml(q) ? `<div class="export-quick-note" role="note"><b>${escapeHtml(scope)}:</b> ${escapeHtml(q.label)}. ${escapeHtml(q.tip || '')}</div>` : '');
14461
- const selected = line(source.quick, source.label);
14764
+ const selected = line(source.quick, source.label)
14765
+ // #2554 slice 2: the selected source's unread drawing files, in their own line (a precise source can have them).
14766
+ + (coveragePillHtml(source.coverage, { besides: source.quick })
14767
+ ? `<div class="export-quick-note is-coverage" role="note"><b>${escapeHtml(source.label)}:</b> ${escapeHtml(source.coverage.text || source.coverage.short)} Files exported from it say so too.</div>` : '');
14462
14768
  // #2521 row 5b: said BEFORE exporting, when this AWARE can only put a Quick model's label in an IFC's names.
14463
14769
  const ifcNamesOnly = quickPillHtml(source.quick) && exportSourcesState.data && exportSourcesState.data.exportProvenance === 'name-only'
14464
14770
  ? '<div class="export-quick-note" role="note">An IFC exported now carries this label in its file name and project name only. Update AWARE from the bottom bar to also write it into the file\'s header and project properties.</div>'
14465
14771
  : '';
14466
14772
  const from = exportStateFrom;
14467
- const files = from && from.quick && exportState && Object.values(exportState).some((e) => e && e.exportedAt)
14468
- && !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version))
14469
- ? line(from.quick, `Files below, exported from v${from.version}`) : '';
14773
+ const filesListed = from && exportState && Object.values(exportState).some((e) => e && e.exportedAt)
14774
+ && !(source.selector.kind === 'latest-approved' && Number(source.version) === Number(from.version));
14775
+ const filesScope = filesListed ? `Files below, exported from v${from.version}` : '';
14776
+ const files = (filesListed && from.quick ? line(from.quick, filesScope) : '')
14777
+ // #2554 slice 2: those files' unread drawing files too, when the version they came from left some.
14778
+ + (filesListed && coveragePillHtml(from.coverage, { besides: from.quick })
14779
+ ? `<div class="export-quick-note is-coverage" role="note"><b>${escapeHtml(filesScope)}:</b> ${escapeHtml(from.coverage.text || from.coverage.short)}</div>` : '');
14470
14780
  return selected + ifcNamesOnly + files;
14471
14781
  }
14472
14782
 
@@ -14547,6 +14857,7 @@
14547
14857
  const approved = projectContractLifecycle === 'model' && exportSourcesState.status === 'ready' && !!currentExportSourceOption();
14548
14858
  const approvalRefusal = approvalRefusalNote();
14549
14859
  // Same 46px band every other project step carries (see the shared step-header rule in app.css).
14860
+ exportsPaintedGate = exportsLifecycleGateKey();
14550
14861
  let html = '<div class="step-head"><span>Exports</span></div>' + exportSourceHtml();
14551
14862
  if (!approved) {
14552
14863
  // Same split as History's empty state (#490): with a model, Approve is genuinely the unlocking
@@ -14568,6 +14879,10 @@
14568
14879
  ? '<div class="ws-exports-gate">Drawing Filter saved &mdash; read the selected drawing content to build the model before exporting.</div>'
14569
14880
  : approvalRefusal
14570
14881
  ? `<div class="ws-exports-gate">${escapeHtml(approvalRefusal)}</div>`
14882
+ : projectContractLifecycle === 'unknown'
14883
+ ? (exportsLifecycleUnanswered
14884
+ ? '<div class="ws-exports-gate">Couldn’t check what this project holds yet. <button type="button" data-exports-lifecycle-retry data-command-id="shell.workspace-stage-recheck#Exports">Try again</button></div>'
14885
+ : '<div class="ws-exports-gate">Checking what this project holds…</div>')
14571
14886
  : hasModel
14572
14887
  ? `<div class="ws-exports-gate">Exports go out after sign-off — ` +
14573
14888
  `<button type="button" id="ws-exports-approve">Approve this version</button> to enable them.</div>`
@@ -14676,23 +14991,51 @@
14676
14991
  * for approval and export. The server therefore returns one authoritative value — `absent`,
14677
14992
  * `filter-checkpoint`, or `model` — and both History and Exports consume that same answer.
14678
14993
  */
14679
- async function projectContractState(projectId, appId) {
14680
- try {
14681
- const url = `/api/projects/${encodeURIComponent(projectId)}/contract-lifecycle?app=${encodeURIComponent(appId)}`;
14682
- // TIMEOUT, because a HANG is not an error and would never reach the catch below. Both callers
14683
- // await this before painting, so without a deadline a wedged connection leaves History reading
14684
- // "Loading history…" and every Exports destination row on "Checking…" indefinitely, with no
14685
- // error and no retry. This GET returns only the small lifecycle envelope, never the contract.
14686
- const res = await fetch(url, { signal: AbortSignal.timeout(4000) });
14687
- // Unknown responses fail closed: approval/export capability is granted only by an explicit
14688
- // `model` lifecycle, never by a successful request with an unexpected body.
14689
- if (!res.ok) return 'unknown';
14690
- const body = await res.json();
14691
- return ['absent', 'filter-checkpoint', 'model'].includes(body && body.lifecycle) ? body.lifecycle : 'unknown';
14692
- } catch {
14693
- // A timeout, network failure, or malformed JSON also fails closed until an authoritative answer
14694
- // can be obtained. `unknown` has its own unavailable UI and is not treated as `absent`.
14994
+ async function projectContractState(projectId, appId, stillWanted) {
14995
+ const budgetMs = 45000, attemptMs = 15000;
14996
+ const url = `/api/projects/${encodeURIComponent(projectId)}/contract-lifecycle?app=${encodeURIComponent(appId)}`;
14997
+ // A SLOW answer is not a missing one (#3139). On a loaded PC this route took 7-10 s while the old
14998
+ // single four-second deadline gave up on every try, so Model never opened however often the
14999
+ // person clicked. Each attempt now gets a longer deadline than the last (15 s, then what is left
15000
+ // of the budget), with a short pause between, until an answer arrives or the budget runs out.
15001
+ // The BUDGET is still a deadline, because a HANG is not an error and would never reach a catch:
15002
+ // every caller awaits this before painting, so without one a wedged connection leaves History
15003
+ // reading "Loading history…" and every Exports destination row on "Checking…" indefinitely.
15004
+ // This GET returns only the small lifecycle envelope, never the contract.
15005
+ // `stillWanted` lets a caller whose answer would be discarded (a project switch, a newer render) stop
15006
+ // asking, so superseded checks do not keep loading the very server that is already slow.
15007
+ const started = Date.now();
15008
+ const deadline = started + budgetMs;
15009
+ // `unknown` has its own unavailable UI and is never treated as `absent`. Say why in the console, since
15010
+ // the person's copy is the same for every cause.
15011
+ const gaveUp = (why, attempts) => {
15012
+ console.warn('[workspaces] project lifecycle check gave up', { projectId, why, attempts, elapsedMs: Date.now() - started });
14695
15013
  return 'unknown';
15014
+ };
15015
+ for (let attempt = 0; ; attempt++) {
15016
+ const remaining = deadline - Date.now();
15017
+ if (remaining <= 0) return gaveUp('out of time', attempt);
15018
+ if (stillWanted && !stillWanted()) return 'unknown';
15019
+ let why = '';
15020
+ try {
15021
+ const res = await fetch(url, { signal: AbortSignal.timeout(Math.min(remaining, attemptMs * 2 ** attempt)) });
15022
+ if (res.ok) {
15023
+ // Unknown responses fail closed: approval/export capability is granted only by an explicit
15024
+ // `model` lifecycle, never by a successful request with an unexpected body.
15025
+ const body = await res.json();
15026
+ return ['absent', 'filter-checkpoint', 'model'].includes(body && body.lifecycle) ? body.lifecycle : gaveUp('unexpected answer', attempt + 1);
15027
+ }
15028
+ // A busy or restarting server (5xx, 408, 429) may answer next time; any other refusal will not.
15029
+ if (!(res.status >= 500 || res.status === 408 || res.status === 429)) return gaveUp(`refused (${res.status})`, attempt + 1);
15030
+ why = `busy (${res.status})`;
15031
+ } catch (err) {
15032
+ // A timeout or network failure is worth another try; malformed JSON from a 200 is not.
15033
+ if (err instanceof SyntaxError) return gaveUp('malformed answer', attempt + 1);
15034
+ why = err && err.name || 'network';
15035
+ }
15036
+ const pause = Math.min(1000 * 2 ** attempt, 5000, deadline - Date.now());
15037
+ if (pause <= 0) return gaveUp(`out of time after ${why}`, attempt + 1);
15038
+ await new Promise((resolve) => setTimeout(resolve, pause));
14696
15039
  }
14697
15040
  }
14698
15041
 
@@ -14822,18 +15165,25 @@
14822
15165
  // inside the pane this fix is for, reachable by opening an empty project and clicking Exports
14823
15166
  // while the open-time probe is still in flight.
14824
15167
  const paintedWith = exportsHasModel;
15168
+ const handed = exportsLifecycleHanded?.gen === renderGen ? exportsLifecycleHanded.present : '';
15169
+ exportsLifecycleHanded = null;
15170
+ exportsLifecycleUnanswered = handed === 'unknown';
14825
15171
  exportSourcesState.status = 'loading';
14826
15172
  paintExports(current.approvedAt, restoreKind);
14827
- const gen = ++modelPresenceGen;
14828
- const modelPresent = await projectContractState(id, app);
15173
+ const gen = handed ? modelPresenceGen : ++modelPresenceGen;
15174
+ exportsLifecycleWait = handed ? 0 : renderGen;
15175
+ const modelPresent = handed || await projectContractState(id, app,
15176
+ () => renderGen === exportsRenderGen && gen === modelPresenceGen && current?.id === id && !$wsExports.hidden);
14829
15177
  // `renderGen` is listed for symmetry with the guard below, and it decides NOTHING here: this
14830
15178
  // function bumps `exportsRenderGen` and then `modelPresenceGen` with no await between them, so a
14831
15179
  // newer render moves both at once and `gen !== modelPresenceGen` has already caught it. The
14832
15180
  // reason `modelPresenceGen` could not simply be reused is real but belongs to the LAST guard,
14833
15181
  // where it is not checked at all. (Review round 5.)
15182
+ // An overtaken render returns here; syncExportsLifecycleGate redoes it when the overtaking check settles.
14834
15183
  if (renderGen !== exportsRenderGen || gen !== modelPresenceGen || !current || current.id !== id || $wsExports.hidden) return;
14835
- applyModelPresence(modelPresent);
14836
- if (exportsHasModel !== paintedWith) paintExports(current.approvedAt, restoreKind);
15184
+ exportsLifecycleWait = 0;
15185
+ if (!handed) applyModelPresence(modelPresent); // repaints the gate when its answer changed; this repaint restores focus too
15186
+ if (exportsHasModel !== paintedWith || exportsLifecycleUnanswered) paintExports(current.approvedAt, restoreKind);
14837
15187
  let state = null;
14838
15188
  let units = null; // the server's answer, applied below the staleness guard with the others
14839
15189
  let filesFrom = null; // #2449: the approved version the listed files came from, same rule
@@ -15444,7 +15794,7 @@
15444
15794
  try {
15445
15795
  await api(endpoint, { method: 'POST', body: JSON.stringify({ path: st.path }) });
15446
15796
  } catch (err) {
15447
- const detail = err && err.body && err.body.error;
15797
+ const detail = personText(err && err.body);
15448
15798
  showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
15449
15799
  }
15450
15800
  }
@@ -15461,7 +15811,7 @@
15461
15811
  try {
15462
15812
  await api(`/api/projects/${encodeURIComponent(projectId)}/exports/open`, { method: 'POST' });
15463
15813
  } catch (err) {
15464
- const detail = err && err.body && err.body.error;
15814
+ const detail = personText(err && err.body);
15465
15815
  const failMsg = 'Couldn’t open the exports folder';
15466
15816
  showToast(detail ? `${failMsg} — ${detail}` : failMsg, 'warn');
15467
15817
  }
@@ -15488,6 +15838,8 @@
15488
15838
  if (e.target.closest('#ws-exports-approve')) { approveProject(); return; }
15489
15839
  // The no-model gate's real next step — mirrors History's #hist-go-drawings.
15490
15840
  if (e.target.closest('#ws-exports-go-drawings')) { chooseStep('drawings'); return; }
15841
+ // #3139: the lifecycle check ran out of time; ask again.
15842
+ if (e.target.closest('[data-exports-lifecycle-retry]')) { safeRenderExports('when you asked to check again'); return; }
15491
15843
  if (e.target.closest('[data-open-exports-folder]')) { openExportsFolder(); return; }
15492
15844
  const details = e.target.closest('[data-export-details]');
15493
15845
  if (details) { showExportReceiptDetails(details.dataset.exportDetails, details); return; }
@@ -15974,7 +16326,7 @@
15974
16326
  const skipped = Array.isArray(out && out.omitted) ? out.omitted.length : 0;
15975
16327
  showToast(`Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
15976
16328
  if (current === proj) { kbInvalidateRefs(); renderKnowledge(); }
15977
- } catch (err) { showToast((err && err.body && err.body.error) || 'Couldn’t add them to the design set. Add them from Knowledge.', 'warn'); }
16329
+ } catch (err) { showToast(personText(err && err.body) || 'Couldn’t add them to the design set. Add them from Knowledge.', 'warn'); }
15978
16330
  } } });
15979
16331
  }
15980
16332
  lastRevState = 'pending';
@@ -16560,6 +16912,29 @@
16560
16912
  if (current && last?.req?.project === current.id) syncFilterFlo(last.req, last.view);
16561
16913
  }
16562
16914
  document.addEventListener('floless:chat-indicator', resyncFilterFlo);
16915
+ // Flo on the 3D model shows what AI Chat is doing on THIS project: the chat's own live mood while it replies, and
16916
+ // Your call while it waits for the person's answer, approval or Do it on a suggested change. Another project's
16917
+ // conversation leaves it idle.
16918
+ function modelFloMood() {
16919
+ const shell = document.getElementById('ai-chat-shell');
16920
+ if (!current || !shell || window.flolessChat?.scopeProjectId?.() !== current.id) return 'idle';
16921
+ if (shell.dataset.approvalPending === 'true') return 'yourcall';
16922
+ const mood = window.flolessChat?.floMood?.();
16923
+ return mood === 'yourcall' || mood === 'thinking' || mood === 'working' ? mood : 'idle';
16924
+ }
16925
+ // The chat changes mood mid-reply without announcing it, so while a model is open the mood is read once a second
16926
+ // (a few in-memory reads) and passed on only when it changed.
16927
+ function syncModelFlo() {
16928
+ const frame = frames.model;
16929
+ if (!frame || !frame.dataset.loaded) { syncModelFlo.sent = null; return; }
16930
+ const mood = modelFloMood();
16931
+ if (mood === syncModelFlo.sent) return;
16932
+ try { frame.contentWindow?.flolessModelFlo?.({ mood }); syncModelFlo.sent = mood; }
16933
+ catch (err) { if (err?.name !== 'SecurityError' && !syncModelFlo.warned) { syncModelFlo.warned = true; console.warn('Flo could not show the AI on the model', err); } }
16934
+ }
16935
+ document.addEventListener('floless:chat-indicator', syncModelFlo);
16936
+ frames.model?.addEventListener('load', () => { syncModelFlo.sent = null; setTimeout(syncModelFlo, 0); });
16937
+ setInterval(syncModelFlo, 1000);
16563
16938
  // #2926: Flo's "Answer in AI Chat" opens the read's own conversation, where the question is.
16564
16939
  window.addEventListener('floless:filter-flo-answer', () => {
16565
16940
  const chatId = syncFilterFlo.last?.req?.chatConversation?.chatId;
@@ -17916,9 +18291,11 @@
17916
18291
  : code === 'revision-request-retired'
17917
18292
  ? 'This review was applied elsewhere and is no longer available. Close this message to see the current project.'
17918
18293
  : 'This drawing read has already been discarded. Close this message to attach the set again.';
18294
+ if (!terminal) console.warn('[revision] discard failed', error);
17919
18295
  $revDiscardError.textContent = terminal
17920
18296
  ? conflictMessage
17921
- : `Couldn’t discard this read. ${(error && error.message) || 'Try again.'}`;
18297
+ // #3097: the shared sentence, never the request's own text: a lost answer may have discarded it anyway.
18298
+ : failureCopy(error, { action: 'discard this read', unsure: 'Reopen the review to check whether it was discarded before trying again.' }).text;
17922
18299
  $revDiscardError.hidden = false;
17923
18300
  $revDiscardDialog.removeAttribute('aria-busy');
17924
18301
  $revDiscardCancel.disabled = false;
@@ -18545,7 +18922,7 @@
18545
18922
  `<td><span class="ver${v.current ? ' cur' : ''}">v${escapeHtml(String(v.n))}</span></td>` +
18546
18923
  `<td class="htime">${escapeHtml(histWhen(v.ts))}</td>` +
18547
18924
  `<td><span class="hby">${avatarFor(v.author)}${escapeHtml(v.author)}</span></td>` +
18548
- `<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}${quickPillHtml(v.quick, { scope: `v${v.n}` })}</td>` +
18925
+ `<td>${gateBadge(v.gate, v.kind, v.n, typeof v.acceptedImportFindingsNote === 'string' ? v.acceptedImportFindingsNote : '')}${quickPillHtml(v.quick, { scope: `v${v.n}` })}${coveragePillHtml(v.coverage, { scope: `v${v.n}`, besides: v.quick })}</td>` +
18549
18926
  `<td class="change">${revisionNoteHtml(v)}${changeCellHtml(v, meta)}${diffStatus}</td>` +
18550
18927
  `<td>${action}</td></tr>`;
18551
18928
  // The disclosure row is always emitted (hidden) so toggling is a pure show/hide + lazy fetch.
@@ -18578,7 +18955,7 @@
18578
18955
  const resume = allowed.includes('resume')
18579
18956
  ? `<button type="button" class="btn-mini" data-resume-checkpoint="${escapeAttr(String(saved.id))}" data-tip="Switch the working copy to this exact saved checkpoint">Resume exact checkpoint</button>`
18580
18957
  : '';
18581
- return `<article class="saved-work-card"><div><b>${escapeHtml(base)}</b>${quickPillHtml(saved.quick, { scope: 'This checkpoint' })}<span>${escapeHtml(histWhen(saved.capturedAt))} · ${escapeHtml(String(saved.id || '').slice(0, 8))}</span></div>`
18958
+ return `<article class="saved-work-card"><div><b>${escapeHtml(base)}</b>${quickPillHtml(saved.quick, { scope: 'This checkpoint' })}${coveragePillHtml(saved.coverage, { scope: 'This checkpoint', besides: saved.quick })}<span>${escapeHtml(histWhen(saved.capturedAt))} · ${escapeHtml(String(saved.id || '').slice(0, 8))}</span></div>`
18582
18959
  + `<p>This checkpoint stays attached to its original approved base; it is never applied backward into another revision.</p>${resume}</article>`;
18583
18960
  }).join('')}</div>`;
18584
18961
  }
@@ -18588,6 +18965,19 @@
18588
18965
  // #2470 R6.5b: each ledger render is numbered, so one overtaken by a newer render (the person went to Activity and back
18589
18966
  // while it was reading) neither paints nor speaks.
18590
18967
  let historyRenderGen = 0;
18968
+ // #3139: the ledger render that is waiting on its lifecycle check (0 when none). A check from elsewhere that bumps
18969
+ // modelPresenceGen overtakes that render, which then returns without painting; syncHistoryLifecycleWait renders
18970
+ // again so the pane is never left on "Loading history…" after every check has stopped.
18971
+ // That render is told (by its generation) that an answer is already applied, so it does not ask the server again; it
18972
+ // reads the latest applied answer when it gets there, because it first awaits the ledger and a newer check may land.
18973
+ let historyLifecycleWait = 0;
18974
+ let historyLifecycleHanded = 0;
18975
+ function syncHistoryLifecycleWait() {
18976
+ if (!historyLifecycleWait || historyLifecycleWait !== historyRenderGen || !current || $wsHistory.hidden) return;
18977
+ historyLifecycleWait = 0;
18978
+ historyLifecycleHanded = historyRenderGen + 1;
18979
+ renderHistory();
18980
+ }
18591
18981
  /**
18592
18982
  * The ledger was on screen and is being hidden (setStep): a render still reading neither paints nor speaks, and a
18593
18983
  * revision-note editor it opened will not reopen or repaint it. A note the person already pressed Save on is still
@@ -18697,10 +19087,15 @@
18697
19087
  //
18698
19088
  // Built with DOM methods rather than innerHTML — the label comes from a descriptor, so it is the
18699
19089
  // same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
18700
- const gen = ++modelPresenceGen;
18701
- const hasModel = await projectContractState(id, current.app);
19090
+ const handed = historyLifecycleHanded === renderGen;
19091
+ historyLifecycleHanded = 0;
19092
+ const gen = handed ? modelPresenceGen : ++modelPresenceGen;
19093
+ historyLifecycleWait = handed ? 0 : renderGen;
19094
+ const hasModel = handed ? projectContractLifecycle : await projectContractState(id, current.app,
19095
+ () => gen === modelPresenceGen && current?.id === id && !$wsHistory.hidden && renderGen === historyRenderGen);
18702
19096
  if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return;
18703
- applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
19097
+ historyLifecycleWait = 0;
19098
+ if (!handed) applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
18704
19099
  const empty = document.createElement('div');
18705
19100
  empty.className = 'hist-empty';
18706
19101
  const emptyRefusal = approvalRefusalNote();
@@ -18717,6 +19112,14 @@
18717
19112
  empty.append(v1, ' and start the ledger.');
18718
19113
  } else if (hasModel === 'filter-checkpoint') {
18719
19114
  empty.append('Drawing Filter saved. Read the selected drawing content to build the model; History starts after the first drawing read is complete.');
19115
+ } else if (hasModel === 'unknown') {
19116
+ // #3139: the check ran out of time. "Nothing here yet" would claim an empty project FloLess never confirmed.
19117
+ const btn = document.createElement('button');
19118
+ btn.type = 'button';
19119
+ btn.id = 'hist-lifecycle-retry';
19120
+ btn.dataset.commandId = 'shell.workspace-stage-recheck#History';
19121
+ btn.textContent = 'Try again';
19122
+ empty.append('Couldn’t check what this project holds yet. ', btn);
18720
19123
  } else {
18721
19124
  const btn = document.createElement('button');
18722
19125
  btn.type = 'button';
@@ -19082,16 +19485,20 @@
19082
19485
  wrap.appendChild(btn);
19083
19486
  return wrap;
19084
19487
  }
19085
- function renderDiffPanel(panel, diff, quick) {
19488
+ function renderDiffPanel(panel, diff, quick, coverage) {
19086
19489
  panel.textContent = '';
19087
19490
  panel.appendChild(diffBasePicker(diff));
19088
19491
  for (const c of diffCautions(diff.warnings)) panel.appendChild(c); // above the numbers — context for reading them
19089
19492
  // #2521 row 5: each side says what IT rests on, above the tonnage, so a Quick side never reads as precise.
19090
19493
  const sides = quick ? [[quick.from, `v${diff.from}`], [quick.to, `v${diff.to}`]].filter(([q]) => quickPillHtml(q)) : [];
19091
- if (sides.length) {
19494
+ // #2554 slice 2: and which drawing files each side did not read, beside its label.
19495
+ const covers = coverage ? [[coverage.from, quick && quick.from, `v${diff.from}`], [coverage.to, quick && quick.to, `v${diff.to}`]]
19496
+ .filter(([c, q]) => coveragePillHtml(c, { besides: q })) : [];
19497
+ if (sides.length || covers.length) {
19092
19498
  const note = el('div', 'hd-quick');
19093
19499
  note.setAttribute('role', 'note');
19094
- note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true })).join(' ');
19500
+ note.innerHTML = sides.map(([q, scope]) => quickPillHtml(q, { scope, showScope: true }))
19501
+ .concat(covers.map(([c, q, scope]) => coveragePillHtml(c, { scope, showScope: true, besides: q }))).join(' ');
19095
19502
  panel.appendChild(note);
19096
19503
  }
19097
19504
  panel.appendChild(diffNetHeader(diff.tonnage));
@@ -19221,8 +19628,9 @@
19221
19628
  // and server ship together, so that window is a half-finished upgrade, not a supported state.
19222
19629
  if (!hasStatus && legacyUnreadableDiff(response.diff)) return { kind: 'unavailable' };
19223
19630
  if (!wellFormedDiff(response.diff)) throw new Error('invalid comparison response');
19631
+ const coverage = response.coverage && typeof response.coverage === 'object' ? { coverage: response.coverage } : {};
19224
19632
  return response.quick && typeof response.quick === 'object'
19225
- ? { kind: 'available', diff: response.diff, quick: response.quick } : { kind: 'available', diff: response.diff };
19633
+ ? { kind: 'available', diff: response.diff, quick: response.quick, ...coverage } : { kind: 'available', diff: response.diff, ...coverage };
19226
19634
  }
19227
19635
  function restoreDiffFocus(panel, n) {
19228
19636
  const target = panel.querySelector('.hd-base')
@@ -19285,7 +19693,7 @@
19285
19693
  panel.setAttribute('aria-busy', 'false');
19286
19694
  if (progress) progress.textContent = '';
19287
19695
  if (decoded.kind === 'unavailable') renderDiffUnavailable(panel);
19288
- else renderDiffPanel(panel, decoded.diff, decoded.quick);
19696
+ else renderDiffPanel(panel, decoded.diff, decoded.quick, decoded.coverage);
19289
19697
  if (opts && opts.restoreBaseFocus) restoreDiffFocus(panel, n);
19290
19698
  }
19291
19699
  function toggleDiff(btn) {
@@ -19426,7 +19834,7 @@
19426
19834
  : `Added to the design set${out && out.label ? ` as “${out.label}”` : ''}${skipped ? `, without ${skipped} file${skipped === 1 ? '' : 's'} it could not store` : ''}`, skipped ? 'warn' : 'ok');
19427
19835
  if (current === proj) kbInvalidateRefs();
19428
19836
  })
19429
- .catch((err) => showToast((err && err.body && typeof err.body.error === 'string' && err.body.error) || 'Couldn’t add these drawings to the design set. Try again.', 'warn'))
19837
+ .catch((err) => showToast(personText(err && err.body) || 'Couldn’t add these drawings to the design set. Try again.', 'warn'))
19430
19838
  .finally(() => dsLand.removeAttribute('aria-busy'));
19431
19839
  return;
19432
19840
  }
@@ -19439,6 +19847,8 @@
19439
19847
  // The no-model empty state's real next step: go read a drawing. Same handler shape as the
19440
19848
  // Approve it replaces, so the pane keeps owning its own inline actions.
19441
19849
  if (e.target.closest('#hist-go-drawings')) { chooseStep('drawings'); return; }
19850
+ // #3139: the lifecycle check ran out of time; ask again from the top.
19851
+ if (e.target.closest('#hist-lifecycle-retry')) { renderHistory(); return; }
19442
19852
  if (e.target.closest('.hc-cancel')) { closeRollbackConfirm(); return; }
19443
19853
  const go = e.target.closest('[data-hc-go]');
19444
19854
  if (go) { rollbackTo(Number(go.dataset.hcGo)); return; }
@@ -19823,51 +20233,185 @@
19823
20233
  // it can start at this project's exact exports directory; the old browser download anchor could be
19824
20234
  // blocked and always targeted Downloads. Cancel is an ordinary no-op. A per-project guard prevents
19825
20235
  // duplicate dialogs without blocking unrelated project actions while the chooser is open.
19826
- async function downloadProjectExport(id, label) {
19827
- const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip`);
19828
- if (!res.ok) throw new Error((await res.json().catch(() => ({}))).error || `HTTP ${res.status}`);
20236
+ async function downloadProjectExport(id, label, choice) {
20237
+ // #2732: the choice made after an oversize warning travels in the query, the same one the Save route takes.
20238
+ const query = new URLSearchParams();
20239
+ if (choice) {
20240
+ query.set('inspected', choice.inspected);
20241
+ if (choice.everything) query.set('everything', 'true');
20242
+ for (const folder of choice.leaveOut) query.append('leaveOut', folder);
20243
+ }
20244
+ const qs = query.toString();
20245
+ const res = await fetch(`/api/projects/${encodeURIComponent(id)}/export.zip${qs ? `?${qs}` : ''}`);
20246
+ if (!res.ok) {
20247
+ const body = await res.json().catch(() => ({}));
20248
+ throw Object.assign(new Error(personText(body) || failureCopy({ status: res.status, body }, { action: 'export this project', retrySafe: true }).text), { status: res.status, body });
20249
+ }
19829
20250
  const blob = await res.blob();
19830
20251
  const cd = res.headers.get('content-disposition') || '';
19831
20252
  const name = (cd.match(/filename="?([^"]+)"?/) || [])[1] || `${label}.zip`;
20253
+ // #2732: what the server actually left out, and whether the archive is within what import accepts (when known).
20254
+ let leftOut = [];
20255
+ try { const parsed = JSON.parse(decodeURIComponent(res.headers.get('x-floless-archive-left-out') || '%5B%5D')); if (Array.isArray(parsed)) leftOut = parsed.filter((f) => typeof f === 'string'); } catch { leftOut = []; }
20256
+ const fit = res.headers.get('x-floless-archive-within-import-limit');
20257
+ const withinImportFileLimit = fit === 'true' ? true : fit === 'false' ? false : null;
19832
20258
  const url = URL.createObjectURL(blob);
19833
20259
  const a = document.createElement('a');
19834
20260
  a.href = url; a.download = name;
19835
20261
  document.body.appendChild(a); a.click(); a.remove();
19836
20262
  setTimeout(() => URL.revokeObjectURL(url), 1000);
19837
- return name;
20263
+ return { filename: name, leftOut, withinImportFileLimit };
19838
20264
  }
19839
20265
 
20266
+ /**
20267
+ * #2732: the question when a project is past the archive bounds. Resolves { leaveOut, everything } (the folders to leave
20268
+ * out, earlier ones kept) or null when the person cancels; nothing is exported until they choose.
20269
+ */
20270
+ let exportOversizeAsk = null;
20271
+ const xoNumber = (value) => Number(value || 0).toLocaleString('en-US');
20272
+ const xoPath = (path) => `<span class="xo-path">${escapeHtml(path)}</span>`;
20273
+ const XO_MAX_LEAVE_OUT = 16;
20274
+ const XO_TITLES = {
20275
+ files: 'Too many files for one archive',
20276
+ folders: 'Too many folders for one archive',
20277
+ depth: 'Folders nested too deep for one archive',
20278
+ time: 'Listing this project’s files is taking too long',
20279
+ };
20280
+ function exportOversizeLead(o) {
20281
+ const lead = {
20282
+ files: `FloLess stopped counting at ${xoNumber(o.limit)} files, the most it can import from one archive.`,
20283
+ folders: `This project holds more than ${xoNumber(o.limit)} folders, more than one archive should hold.`,
20284
+ depth: `A folder inside ${xoPath(String(o.deepFolder || '').split('/').slice(0, 2).join('/'))} is nested more than ${xoNumber(o.limit)} folders deep.`,
20285
+ time: `FloLess was still listing this project’s files after ${xoNumber(o.limit / 1000)} seconds.`,
20286
+ }[o.reason] || 'This project has more files than one archive should hold.';
20287
+ const seen = o.folder && o.folderFiles > 0 && o.reason !== 'depth'
20288
+ ? ` At least ${xoNumber(o.folderFiles)} of the files it saw are in ${xoPath(o.folder)}.` : '';
20289
+ return lead + seen;
20290
+ }
20291
+ function askExportOversize(oversize) {
20292
+ const root = document.getElementById('export-oversize-modal');
20293
+ if (!root) return Promise.resolve(null);
20294
+ if (exportOversizeAsk) exportOversizeAsk.close(null);
20295
+ const o = oversize || {};
20296
+ const leftOut = Array.isArray(o.leftOut) ? o.leftOut : [];
20297
+ const canLeaveOut = !!o.folder && leftOut.length < XO_MAX_LEAVE_OUT;
20298
+ const $leave = document.getElementById('xo-leave-out');
20299
+ const $everything = document.getElementById('xo-everything');
20300
+ const $leftOut = document.getElementById('xo-left-out');
20301
+ const returnTo = document.activeElement instanceof HTMLElement ? document.activeElement : null;
20302
+ document.getElementById('xo-title').textContent = XO_TITLES[o.reason] || XO_TITLES.files;
20303
+ document.getElementById('xo-sub').innerHTML = exportOversizeLead(o);
20304
+ const leaveLine = canLeaveOut
20305
+ ? `<li><b>Leave this folder out</b> — faster. The archive holds a note naming what was left out.</li>`
20306
+ : `<li>No folder FloLess saw can be left out${o.folder ? ` (one archive can leave out at most ${XO_MAX_LEAVE_OUT})` : ': only folders inside knowledge or exports can be'}.</li>`;
20307
+ document.getElementById('xo-choices').innerHTML = leaveLine
20308
+ + `<li><b>Export everything</b> — slower. FloLess can import an archive of up to 10,000 files (and 2 GB once unzipped).</li>`;
20309
+ const shown = leftOut.slice(0, 3).map(escapeHtml).join(', ') + (leftOut.length > 3 ? ` +${leftOut.length - 3} more` : '');
20310
+ $leftOut.hidden = !leftOut.length;
20311
+ $leftOut.innerHTML = leftOut.length ? `Already left out, and staying out: ${shown}` : '';
20312
+ $leave.hidden = !canLeaveOut;
20313
+ // With nothing to leave out, Export everything is the one way forward, so it is the primary button.
20314
+ $everything.classList.toggle('primary', !canLeaveOut);
20315
+ $everything.textContent = leftOut.length ? 'Export the rest' : 'Export everything';
20316
+ return new Promise((resolve) => {
20317
+ const close = (result) => {
20318
+ if (exportOversizeAsk !== ask) return;
20319
+ exportOversizeAsk = null;
20320
+ root.classList.remove('show');
20321
+ root.removeEventListener('click', onClick);
20322
+ document.removeEventListener('keydown', onKey, true);
20323
+ if (returnTo && returnTo.isConnected) returnTo.focus();
20324
+ resolve(result);
20325
+ };
20326
+ function onClick(event) {
20327
+ const target = event.target instanceof Element ? event.target : null;
20328
+ if (!target) return;
20329
+ if (target.closest('#xo-cancel')) close(null);
20330
+ else if (target.closest('#xo-everything')) close({ leaveOut: leftOut, everything: true });
20331
+ else if (target.closest('#xo-leave-out') && canLeaveOut) close({ leaveOut: [...leftOut, o.folder], everything: false });
20332
+ }
20333
+ function onKey(event) {
20334
+ if (!root.classList.contains('show')) return;
20335
+ if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); close(null); return; }
20336
+ if (event.key !== 'Tab') return;
20337
+ const focusable = Array.from(root.querySelectorAll('button')).filter((element) => !element.hidden && element.getClientRects().length);
20338
+ if (!focusable.length) return;
20339
+ const first = focusable[0]; const last = focusable[focusable.length - 1];
20340
+ if (event.shiftKey && (document.activeElement === first || !root.contains(document.activeElement))) { event.preventDefault(); last.focus(); }
20341
+ else if (!event.shiftKey && (document.activeElement === last || !root.contains(document.activeElement))) { event.preventDefault(); first.focus(); }
20342
+ }
20343
+ const ask = { close };
20344
+ exportOversizeAsk = ask;
20345
+ root.addEventListener('click', onClick);
20346
+ document.addEventListener('keydown', onKey, true);
20347
+ root.classList.add('show');
20348
+ (canLeaveOut ? $leave : $everything).focus();
20349
+ });
20350
+ }
20351
+ onBackdropDismiss(document.getElementById('export-oversize-modal'), () => { if (exportOversizeAsk) exportOversizeAsk.close(null); }, () => !!exportOversizeAsk);
20352
+
19840
20353
  async function exportProject(id) {
19841
20354
  if (projectExportBusy.has(id)) return;
19842
20355
  const proj = projects.find((p) => p.id === id);
19843
20356
  const label = proj ? proj.name : id;
19844
20357
  projectExportBusy.add(id);
19845
- const dismissProgress = showToast(`Exporting “${label}”…`, 'progress');
19846
- let progressVisible = true;
20358
+ let dismissProgress = null;
20359
+ const startProgress = () => { if (!dismissProgress) dismissProgress = showToast(`Exporting “${label}”…`, 'progress'); };
19847
20360
  const finishProgress = () => {
19848
- if (!progressVisible) return;
19849
- progressVisible = false;
19850
- dismissProgress();
20361
+ if (!dismissProgress) return;
20362
+ const dismiss = dismissProgress;
20363
+ dismissProgress = null;
20364
+ dismiss();
20365
+ };
20366
+ // #2732: the Save route first, the browser download where the Save dialog is unavailable; both take the same choice.
20367
+ let viaDownload = false;
20368
+ const exportOnce = async (choice) => {
20369
+ if (!viaDownload) {
20370
+ try {
20371
+ return await api(`/api/projects/${encodeURIComponent(id)}/export/save`, { method: 'POST', body: JSON.stringify(choice ? { oversize: choice } : {}) });
20372
+ } catch (err) {
20373
+ if (!(err && err.body && err.body.code === 'native-save-unavailable')) throw err;
20374
+ viaDownload = true;
20375
+ }
20376
+ }
20377
+ return downloadProjectExport(id, label, choice);
19851
20378
  };
19852
20379
  try {
19853
- const result = await api(`/api/projects/${encodeURIComponent(id)}/export/save`, { method: 'POST', body: '{}' });
19854
- finishProgress();
19855
- if (result.cancelled) return;
19856
- showToast(`Exported “${label}” — ${result.filename}`, 'ok');
19857
- track('workspace_project_exported', { app: proj ? proj.app : undefined });
19858
- } catch (err) {
19859
- if (err && err.body && err.body.code === 'native-save-unavailable') {
20380
+ let choice = null;
20381
+ for (;;) {
20382
+ startProgress();
20383
+ let result;
19860
20384
  try {
19861
- const filename = await downloadProjectExport(id, label);
19862
- finishProgress();
19863
- showToast(`Exported “${label}” — ${filename}`, 'ok');
19864
- track('workspace_project_exported', { app: proj ? proj.app : undefined });
19865
- return;
19866
- } catch (fallbackError) {
19867
- err = fallbackError;
20385
+ result = await exportOnce(choice);
20386
+ } catch (err) {
20387
+ const body = err && err.body;
20388
+ if (body && body.code === 'archive-oversize' && body.oversize) {
20389
+ finishProgress();
20390
+ const picked = await askExportOversize(body.oversize);
20391
+ if (!picked) return;
20392
+ choice = { inspected: body.oversize.inspected, leaveOut: picked.leaveOut, everything: picked.everything };
20393
+ continue;
20394
+ }
20395
+ throw err;
19868
20396
  }
20397
+ finishProgress();
20398
+ if (result.cancelled) return;
20399
+ const leftOut = Array.isArray(result.leftOut) ? result.leftOut : [];
20400
+ showToast(`Exported “${label}” — ${result.filename}${leftOut.length ? `, without ${leftOut.join(', ')}. The archive notes what was left out.` : ''}`, 'ok');
20401
+ if (result.withinImportFileLimit === false) {
20402
+ showToast('This archive holds more than 10,000 files, so FloLess can’t import it. Unzip it by hand to use its files.', 'warn');
20403
+ }
20404
+ track('workspace_project_exported', { app: proj ? proj.app : undefined });
20405
+ return;
19869
20406
  }
20407
+ } catch (err) {
19870
20408
  finishProgress();
20409
+ const body = err && err.body;
20410
+ // A choice made for a project that was replaced while the person chose, or a refused choice: the server's sentence.
20411
+ if (body && (body.code === 'archive-project-changed' || body.code === 'invalid-export-choice') && typeof body.error === 'string') {
20412
+ showToast(body.error, 'warn');
20413
+ return;
20414
+ }
19871
20415
  showToast(`We couldn’t export “${label}” because FloLess could not finish preparing it. Try again.`, 'warn');
19872
20416
  } finally {
19873
20417
  finishProgress();
@@ -20271,7 +20815,8 @@
20271
20815
  await setMode('workspaces');
20272
20816
  if (current) await leaveProjectToList(returnFocus);
20273
20817
  if (current) return false;
20274
- const archived = $landing.querySelector('.ws-archived');
20818
+ // #3082: coming from another page, the list draws a moment after the switch; wait for it (bounded) before opening it.
20819
+ const archived = await landingPart('.ws-archived');
20275
20820
  if (archived) { archived.open = true; archived.scrollIntoView?.({ block: 'nearest' }); archived.querySelector('summary')?.focus?.(); }
20276
20821
  return true;
20277
20822
  }
@@ -20284,6 +20829,86 @@
20284
20829
  if (current?.id !== projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
20285
20830
  }
20286
20831
 
20832
+ /**
20833
+ * #3082: open the one project a suggestion card named — by its id, and only while it is still that incarnation — at the
20834
+ * step it named (`model` or `history`) when that kind of project has it. Opening is all it does: nothing is approved,
20835
+ * compiled, run or exported. Resolves `{ ok: true, said? }`, `said` being a sentence when the project opened at another
20836
+ * step than asked; throws a sentence written for the person (`plain`) when it did not open.
20837
+ */
20838
+ let suggestedOpenSeq = 0;
20839
+ /** A card's press claims its place in line when pressed, before any check, so a later press always wins. */
20840
+ function claimSuggestedOpen() { return ++suggestedOpenSeq; }
20841
+ async function openSuggestedProject(target, ticket) {
20842
+ // The latest navigation wins: a press whose check is still waiting gives way to a later card or any other open.
20843
+ const mine = Number.isInteger(ticket) ? ticket : claimSuggestedOpen();
20844
+ let navAtStart = openNavSeq;
20845
+ const overtaken = () => mine !== suggestedOpenSeq || openNavSeq !== navAtStart;
20846
+ const fail = (sentence) => Object.assign(new Error(sentence), { plain: true });
20847
+ const projectId = target?.id;
20848
+ const name = typeof target?.name === 'string' && target.name ? target.name : 'That project';
20849
+ if (typeof projectId !== 'string' || !projectId) throw fail('That project could not be opened. Open it from Workspaces.');
20850
+ await setMode('workspaces');
20851
+ if (mode !== 'workspaces') throw fail(`You stayed where you were, so ${name} was not opened.`);
20852
+ if (mine !== suggestedOpenSeq) return { superseded: true };
20853
+ navAtStart = openNavSeq; // switching to Workspaces may itself navigate; count only what happens from here
20854
+ // The list as the server has it now, so a project made again under the same id is never opened in its place.
20855
+ // A list that cannot be read proves nothing, so nothing is opened on it.
20856
+ let row = null;
20857
+ try { row = (await api('/api/projects')).projects.find((p) => p.id === projectId) || null; }
20858
+ catch (error) {
20859
+ if (overtaken()) return { superseded: true };
20860
+ console.warn('[workspaces] could not read the projects to open a suggested one:', error);
20861
+ throw fail(`FloLess couldn’t check ${name} just now, so it was not opened. Try again in a moment.`);
20862
+ }
20863
+ if (overtaken()) return { superseded: true };
20864
+ const sameIncarnation = (p) => !target.uuid || p?.uuid === target.uuid;
20865
+ if (!row || !sameIncarnation(row)) throw fail(`${name} is no longer in this workspace, so it was not opened. Choose a project on Workspaces.`);
20866
+ const want = target.step === 'history' ? 'history' : target.step === 'model' ? 'model' : null;
20867
+ const hasStep = (key) => Boolean(wsDescOf(row)?.steps?.some((st) => st.key === key));
20868
+ // This window still holds an older project under the same id (open, or in its list): opening by id would open that
20869
+ // one, and would skip the unsaved-work question for it. Open nothing; Workspaces reads the list again.
20870
+ const older = (current?.id === projectId && !sameIncarnation(current)) || projects.some((p) => p.id === projectId && !sameIncarnation(p));
20871
+ if (older) throw fail(`This window still shows an older project in ${name}’s place, so it was not opened. Go back to all projects, then open ${name} from Workspaces.`);
20872
+ if (current?.id === projectId) {
20873
+ // Already open: only its step changes, so nothing loaded in the editor is reset.
20874
+ if (want && hasStep(want) && currentStep !== want) setStep(want);
20875
+ } else {
20876
+ const opened = await openProject(projectId, want && hasStep(want) ? want : 'model');
20877
+ if (opened === STAYED_IN_PROJECT) throw fail(`You stayed in this project, so ${name} was not opened.`);
20878
+ if (current?.id !== projectId) throw fail(`${name} could not be opened. Open it from Workspaces to see why.`);
20879
+ if (!sameIncarnation(current)) throw fail(`The project open now is not the ${name} the suggestion named. Choose a project on Workspaces.`);
20880
+ }
20881
+ if (!want) return { ok: true };
20882
+ const label = want === 'history' ? 'History' : 'Model';
20883
+ if (!hasStep(want)) return { ok: true, said: `${name} has no ${label} step, so it opened at ${stepLabel(currentStep)}.` };
20884
+ // A step the project's stages keep locked: say where it opened and the stage's own reason. A step still being checked
20885
+ // opens by itself once it can.
20886
+ if (currentStep !== want && pendingPresenceStep?.step !== want) {
20887
+ const reason = stageGateFor(want);
20888
+ return { ok: true, said: `${name} opened at ${stepLabel(currentStep)}, because its ${label} step isn’t available yet.${reason ? ` ${reason}` : ''}` };
20889
+ }
20890
+ return { ok: true };
20891
+ }
20892
+
20893
+ /** #3082: the Workspaces list itself, for choosing a project when the one a suggestion named is gone. */
20894
+ async function showProjectList(returnFocus) {
20895
+ await setMode('workspaces');
20896
+ if (current) await leaveProjectToList(returnFocus);
20897
+ if (current) return false;
20898
+ (await landingPart('[data-open]'))?.focus?.();
20899
+ return true;
20900
+ }
20901
+
20902
+ /** One part of the Workspaces list, once it is drawn: up to five seconds after a page switch, else null. */
20903
+ async function landingPart(selector) {
20904
+ for (let i = 0; i < 25; i++) {
20905
+ const found = $landing.querySelector(selector);
20906
+ if (found) return found;
20907
+ await new Promise((resolve) => setTimeout(resolve, 200));
20908
+ }
20909
+ return null;
20910
+ }
20911
+
20287
20912
  // The Drawing Filter step of a project, where a drawing read's exclusions are saved and signed off.
20288
20913
  async function openDrawingsStep(projectId) {
20289
20914
  if (typeof projectId !== 'string' || !projectId) throw new Error('That project could not be opened. Open it from Workspaces.');
@@ -20803,6 +21428,8 @@
20803
21428
  openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openWorkflowsStep, openConnection, openDrawingAt, drawingFilterCheckpointSaved,
20804
21429
  // #2470 R6.7: the Modules step of a General project (project-modules.js).
20805
21430
  moduleCreateCardsHtml, activateCreateCard, openNewProjectFromDrawings, openLinkedProject, openModulesStep, showArchivedProjects,
21431
+ // #3082: a Guide or assistant card that names one project, and where to choose another when it is gone.
21432
+ openSuggestedProject, claimSuggestedOpen, showProjectList,
20806
21433
  syncWorkspaceReporter, openChatOwner, openPagesHome, folderDecisionCompleted,
20807
21434
  // Project access (project-access.js loads after this file): the project open now, or null.
20808
21435
  currentProject: () => ($app.classList.contains('mode-workspaces') && current ? current : null),