@floless/app 0.167.0 → 0.168.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 (257) hide show
  1. package/autostart.mjs +169 -63
  2. package/desktop-shell.mjs +335 -0
  3. package/dist/floless-server.cjs +14518 -11361
  4. package/dist/schemas/steel.model.v2.schema.json +2 -1
  5. package/dist/skills/floless-app-onboarding/SKILL.md +13 -4
  6. package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +3 -0
  7. package/dist/skills/floless-app-steel-takeoff/SKILL.md +21 -2
  8. package/dist/skills/floless-app-ui/SKILL.md +2 -2
  9. package/dist/skills/floless-app-workflows/SKILL.md +2 -2
  10. package/dist/web/agents.js +1 -1
  11. package/dist/web/app.css +165 -8
  12. package/dist/web/app.js +53 -13
  13. package/dist/web/aware-update-client.js +13 -5
  14. package/dist/web/aware.js +183 -39
  15. package/dist/web/chat.css +2 -1
  16. package/dist/web/chat.js +410 -80
  17. package/dist/web/commands-filter.js +5 -5
  18. package/dist/web/commands-shell.js +172 -10
  19. package/dist/web/commands-steel.js +1 -1
  20. package/dist/web/desktop-window.js +435 -0
  21. package/dist/web/drawing-check-editor.js +18 -10
  22. package/dist/web/failure-copy.js +14 -1
  23. package/dist/web/guide.js +75 -9
  24. package/dist/web/index.html +64 -6
  25. package/dist/web/instructor.js +1 -1
  26. package/dist/web/leave-guard.js +347 -14
  27. package/dist/web/pages.js +5 -1
  28. package/dist/web/panels.js +5 -2
  29. package/dist/web/pdf-view.js +421 -0
  30. package/dist/web/project-history.js +2 -1
  31. package/dist/web/project-modules.js +3 -1
  32. package/dist/web/project-rfis.js +3 -1
  33. package/dist/web/project-workflows.js +4 -2
  34. package/dist/web/reference-geometry-worker.js +11 -2
  35. package/dist/web/revit-editor.html +1 -0
  36. package/dist/web/revit-editor.js +37 -8
  37. package/dist/web/shared-prefs.js +364 -0
  38. package/dist/web/steel-editor.html +204 -43
  39. package/dist/web/steel-filter-flo.js +74 -18
  40. package/dist/web/steel-filter.html +22 -6
  41. package/dist/web/tab-signal.js +36 -1
  42. package/dist/web/tekla-editor.html +1 -0
  43. package/dist/web/tool-updates.js +159 -38
  44. package/dist/web/vector-3d.html +14 -3
  45. package/dist/web/vector-editor.html +10 -2
  46. package/dist/web/vendor/README.md +23 -0
  47. package/dist/web/vendor/pdfjs/LICENSE +177 -0
  48. package/dist/web/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  49. package/dist/web/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  50. package/dist/web/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  51. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  52. package/dist/web/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  53. package/dist/web/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  54. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  55. package/dist/web/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  56. package/dist/web/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  57. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  58. package/dist/web/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  59. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  60. package/dist/web/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  61. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  62. package/dist/web/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  63. package/dist/web/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  64. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  65. package/dist/web/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  66. package/dist/web/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  67. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  68. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  69. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  70. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  71. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  72. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  73. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  74. package/dist/web/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  75. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  76. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  77. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  78. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  79. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  80. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  81. package/dist/web/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  82. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  83. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  84. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  85. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  86. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  87. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  88. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  89. package/dist/web/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  90. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  91. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  92. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  93. package/dist/web/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  94. package/dist/web/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  95. package/dist/web/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  96. package/dist/web/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  97. package/dist/web/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  98. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  99. package/dist/web/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  100. package/dist/web/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  101. package/dist/web/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  102. package/dist/web/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  103. package/dist/web/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  104. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  105. package/dist/web/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  106. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  107. package/dist/web/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  108. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  109. package/dist/web/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  110. package/dist/web/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  111. package/dist/web/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  112. package/dist/web/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  113. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  114. package/dist/web/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  115. package/dist/web/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  116. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  117. package/dist/web/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  118. package/dist/web/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  119. package/dist/web/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  120. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  121. package/dist/web/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  122. package/dist/web/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  123. package/dist/web/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  124. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  125. package/dist/web/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  126. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  127. package/dist/web/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  128. package/dist/web/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  129. package/dist/web/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  130. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  131. package/dist/web/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  132. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  133. package/dist/web/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  134. package/dist/web/vendor/pdfjs/cmaps/H.bcmap +0 -0
  135. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  136. package/dist/web/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  137. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  138. package/dist/web/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  139. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  140. package/dist/web/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  141. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  142. package/dist/web/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  143. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  144. package/dist/web/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  145. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  146. package/dist/web/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  147. package/dist/web/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  148. package/dist/web/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  149. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  150. package/dist/web/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  151. package/dist/web/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  152. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  153. package/dist/web/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  154. package/dist/web/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  155. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  156. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  157. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  158. package/dist/web/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  159. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  160. package/dist/web/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  161. package/dist/web/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  162. package/dist/web/vendor/pdfjs/cmaps/LICENSE +36 -0
  163. package/dist/web/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  164. package/dist/web/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  165. package/dist/web/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  166. package/dist/web/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  167. package/dist/web/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  168. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  169. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  170. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  171. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  172. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  173. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  174. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  175. package/dist/web/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  176. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  177. package/dist/web/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  178. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  179. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  180. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  181. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  182. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  183. package/dist/web/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  184. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  185. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  186. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  187. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  188. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  189. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  190. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  191. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  192. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  193. package/dist/web/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  194. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  195. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  196. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  197. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  198. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  199. package/dist/web/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  200. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  201. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  202. package/dist/web/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  203. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  204. package/dist/web/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  205. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  206. package/dist/web/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  207. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  208. package/dist/web/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  209. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  210. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  211. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  212. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  213. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  214. package/dist/web/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  215. package/dist/web/vendor/pdfjs/cmaps/V.bcmap +0 -0
  216. package/dist/web/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  217. package/dist/web/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  218. package/dist/web/vendor/pdfjs/iccs/LICENSE +116 -0
  219. package/dist/web/vendor/pdfjs/pdf.min.mjs +28 -0
  220. package/dist/web/vendor/pdfjs/pdf.worker.mjs +64908 -0
  221. package/dist/web/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  222. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  223. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  224. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  225. package/dist/web/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  226. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  227. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  228. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  229. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  230. package/dist/web/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  231. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  232. package/dist/web/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  233. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  234. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  235. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  236. package/dist/web/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  237. package/dist/web/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  238. package/dist/web/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  239. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  240. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  241. package/dist/web/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  242. package/dist/web/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  243. package/dist/web/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  244. package/dist/web/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +15 -0
  245. package/dist/web/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  246. package/dist/web/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +17 -0
  247. package/dist/web/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  248. package/dist/web/workspaces.js +167 -26
  249. package/home-env.mjs +28 -0
  250. package/install-path.mjs +59 -3
  251. package/launch-starting-page.mjs +35 -15
  252. package/launch.mjs +358 -51
  253. package/package.json +2 -1
  254. package/pin-home.mjs +6 -0
  255. package/post-update-marker.mjs +14 -0
  256. package/preferences-file.mjs +289 -0
  257. package/supervisor-lock.mjs +195 -0
package/dist/web/chat.js CHANGED
@@ -75,6 +75,9 @@
75
75
  // Latched so the 5 s account poll logs an outage once instead of twelve times a minute; cleared
76
76
  // on the next successful read, so a later, separate outage is logged too.
77
77
  accountReadWarned: false,
78
+ // #3095: what the feed was drawn from at the last poll that repainted it (feedPollKey), and whether the feed's last
79
+ // draw, by anyone, finished: unchanged and finished, the poll leaves the feed be.
80
+ feedPollKey: undefined, feedDrawn: false,
78
81
  // The last sentence a suggestion card's action reported, keyed by the card's request id.
79
82
  filterCardMessages: new Map(),
80
83
  // #1859: per message (client submission id), why the open Drawing Filter's selection did not go with it.
@@ -200,9 +203,24 @@
200
203
  throw error;
201
204
  }
202
205
  const contentType = response.headers.get('content-type') || '';
203
- const body = contentType.includes('application/json') ? await response.json() : await response.text();
206
+ const readOnly = /^(GET|HEAD)$/.test(String(options.method || 'GET').toUpperCase());
207
+ // #3097: JSON that does not parse is an answer this window could not read: the parser's own text goes to the console,
208
+ // the person reads the shared sentence.
209
+ const unreadable = (cause) => {
210
+ console.warn('[chat] a request was answered with JSON this window could not read', path, response.status, cause);
211
+ return Object.assign(new Error(failureCopy({ status: response.status, body: { ok: false, code: 'response-unreadable' } }, { retrySafe: readOnly }).text),
212
+ { code: 'response-unreadable', status: response.status });
213
+ };
214
+ const body = contentType.includes('application/json')
215
+ ? await response.json().catch((cause) => { if (response.ok) throw unreadable(cause); return null; })
216
+ : await response.text();
204
217
  if (!response.ok) {
205
- const error = new Error(body?.error || body || `Chat request failed (${response.status})`);
218
+ // #3097: the server's own sentence when it wrote one, else the shared one; never "(<status>)". A text answer (an
219
+ // HTML error page, a proxy's plain text) is not FloLess's JSON, so it goes to the console, never into the message.
220
+ const json = body && typeof body === 'object' ? body : null;
221
+ if (!json) console.warn('[chat] a request was answered with something other than FloLess JSON', path, response.status, String(body ?? '').slice(0, 200));
222
+ const said = typeof json?.error === 'string' && json.error ? json.error : '';
223
+ const error = new Error(said || failureCopy({ status: response.status, body: json || {} }, { retrySafe: readOnly }).text);
206
224
  error.code = body?.code || null;
207
225
  error.reason = body?.reason || null;
208
226
  error.recovery = Array.isArray(body?.recovery) ? body.recovery : null;
@@ -841,10 +859,17 @@
841
859
  return { text: stream.shown, streaming: stream.shown.length < stream.target.length };
842
860
  }
843
861
 
862
+ // Read state is shared between the FloLess window and the browser tab through web/shared-prefs.js (#2963); without it, this browser's own storage.
844
863
  function readCursor(chatId) {
864
+ if (window.flolessPrefs) return window.flolessPrefs.chatCursor(chatId);
845
865
  try { return Number(localStorage.getItem(`floless:chat-read:${chatId}`) || 0); } catch { return 0; }
846
866
  }
847
867
 
868
+ function storeReadCursor(chatId, sequence) {
869
+ if (window.flolessPrefs) { window.flolessPrefs.markChatRead(chatId, sequence); return; }
870
+ try { localStorage.setItem(`floless:chat-read:${chatId}`, String(sequence)); } catch { /* private mode */ }
871
+ }
872
+
848
873
  function isUnreadConversation(chat) {
849
874
  return Boolean(chat) && (chat.lastEventSequence || 0) > readCursor(chat.chatId);
850
875
  }
@@ -852,9 +877,23 @@
852
877
  // A browser seeing an owner's history for the first time has no honest way to call its existing
853
878
  // backlog unread. Establish a one-time baseline, then retain unread state for conversations that
854
879
  // receive later events. This prevents a migrated chat history from showing hundreds of old events.
855
- function seedReadCursors(chats, owner = state.scope?.owner) {
880
+ async function seedReadCursors(chats, owner = state.scope?.owner) {
856
881
  if (!owner) return;
857
882
  const ownerId = owner.kind === 'project' ? owner.projectId : owner.kind === 'workflow' ? owner.workflowId : 'workspace';
883
+ // Shared (#2963): the baseline is taken once per owner across the window and the browser tab, after the server's answer is in. A client
884
+ // that finds the owner already seeded sets nothing, so a chat the server has no cursor for stays unread. Without the server it falls back to
885
+ // this browser's own one-time baseline (inside seedOwner).
886
+ if (window.flolessPrefs) {
887
+ const cursors = {};
888
+ for (const chat of chats.slice(0, 500)) cursors[chat.chatId] = chat.lastEventSequence || 0;
889
+ // History must never wait on the preferences queue: past ~5 s the baseline is taken from this browser's own storage instead.
890
+ let timer;
891
+ const limit = new Promise((resolve) => { timer = setTimeout(() => resolve(false), 5000); });
892
+ const seeded = window.flolessPrefs.seedOwner(`${owner.kind}:${ownerId}`, cursors).then(() => true, () => true);
893
+ const inTime = await Promise.race([seeded, limit]);
894
+ clearTimeout(timer);
895
+ if (inTime) return;
896
+ }
858
897
  const key = `floless:chat-read-seeded:${owner.kind}:${ownerId}`;
859
898
  try {
860
899
  if (localStorage.getItem(key)) return;
@@ -866,14 +905,14 @@
866
905
  function markRead(chat = state.chat) {
867
906
  if (!chat || document.hidden || ui.feed.closest('[hidden]')
868
907
  || document.querySelector('.app')?.classList.contains('left-collapsed')) return;
869
- try { localStorage.setItem(`floless:chat-read:${chat.chatId}`, String(chat.lastEventSequence || 0)); } catch { /* private mode */ }
908
+ storeReadCursor(chat.chatId, chat.lastEventSequence || 0);
870
909
  paintUnread();
871
910
  }
872
911
 
873
912
  function markReadThrough(chat, sequence) {
874
913
  if (!chat) return;
875
914
  const through = Math.max(readCursor(chat.chatId), Math.min(Number(sequence) || 0, chat.lastEventSequence || 0));
876
- try { localStorage.setItem(`floless:chat-read:${chat.chatId}`, String(through)); } catch { /* private mode */ }
915
+ storeReadCursor(chat.chatId, through);
877
916
  paintUnread();
878
917
  }
879
918
 
@@ -2378,6 +2417,13 @@
2378
2417
  const CITATION_READ = {
2379
2418
  'whole-sheet': 'yes, the whole sheet', tiles: 'yes, enlarged in 9 tiles', yes: 'yes', no: 'no', unknown: 'not recorded',
2380
2419
  };
2420
+ /** #3093: where a single enlarged tile sits on its sheet, left to right and top to bottom. */
2421
+ const TILE_PLACES = ['', 'top-left', 'top-middle', 'top-right', 'middle-left', 'middle', 'middle-right', 'bottom-left', 'bottom-middle', 'bottom-right'];
2422
+ /** The one tile the AI was shown, or 0 when it saw the sheet whole or all its tiles. */
2423
+ const citedTile = (entry) => {
2424
+ const part = entry?.read === 'tiles' ? entry.ref?.part : undefined;
2425
+ return Number.isSafeInteger(part) && part >= 1 && part <= 9 ? part : 0;
2426
+ };
2381
2427
 
2382
2428
  function citationIndex(turnId) {
2383
2429
  const byAnchor = new Map();
@@ -2411,16 +2457,17 @@
2411
2457
  const row = byAnchor.get(anchor);
2412
2458
  if (!row) continue;
2413
2459
  row.choices = made;
2414
- const live = made.filter((choice) => decisionLiveOn(row, choice)).at(-1);
2460
+ // #3100: a choice the person went on from as an assumption, after its source was found gone, is history.
2461
+ const live = made.filter((choice) => !choice.superseded && decisionLiveOn(row, choice)).at(-1);
2415
2462
  if (live) row.choice = live;
2416
2463
  }
2417
- // #2642: the person's assumption. The live one (none while a live choice stands) is the claim's current decision;
2418
- // otherwise its first record is history ("Earlier assumed").
2464
+ // #2642: the person's assumption. The live one (none while a live choice stands; #3100 the latest when two hold) is
2465
+ // the claim's current decision; otherwise its first record is history ("Earlier assumed").
2419
2466
  for (const record of citationAssumptions(turnId)) {
2420
2467
  const row = byAnchor.get(record.anchor);
2421
2468
  if (!row) continue;
2422
2469
  const live = !row.choice && decisionLiveOn(row, record);
2423
- if (live && !row.assumptionLive) { row.assumption = record; row.assumptionLive = true; }
2470
+ if (live) { row.assumption = record; row.assumptionLive = true; }
2424
2471
  else if (!row.assumption) row.assumption = record;
2425
2472
  }
2426
2473
  // #3000: an entry the answer never marks is not a claim: it is listed apart as "Also consulted", unnumbered, and
@@ -2529,23 +2576,63 @@
2529
2576
  const out = new Map();
2530
2577
  if (!turnId) return out;
2531
2578
  const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2532
- for (const event of state.events) {
2533
- if (event.type !== 'citation-choice') continue;
2579
+ const byId = new Map();
2580
+ state.events.forEach((event, at) => {
2581
+ if (event.type === 'citation-assumption') {
2582
+ // #3100: an assumption recorded on a chosen source found gone supersedes the earlier choice of this claim it names
2583
+ // (`supersededChoiceIds`): the choice stays on record as made, and is history from then on.
2584
+ const named = assumptionRecordOf(event, turnId)?.chosenGone;
2585
+ const choice = named ? byId.get(named.choiceId) : null;
2586
+ const p = event.payload;
2587
+ // The named choice and every earlier one of the claim: one it replaced must never become its source again.
2588
+ if (choice && choice.anchor === p.anchor && choice.citationId.toLowerCase() === p.citationId.toLowerCase() && claimHeld(p.citationId, turnId, p.anchor)) {
2589
+ for (const earlier of out.get(p.anchor) ?? []) { earlier.superseded = true; if (earlier === choice) break; }
2590
+ }
2591
+ return;
2592
+ }
2593
+ if (event.type !== 'citation-choice') return;
2534
2594
  const p = event.payload || {};
2535
2595
  if (p.turnId !== turnId || typeof p.turnId !== 'string' || !uuid.test(p.turnId) || typeof p.citationId !== 'string' || !uuid.test(p.citationId)
2536
2596
  || typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || !(p.claim === null || citeText(p.claim, 300))
2537
- || !citeText(p.chosenBy, 200) || !citeText(p.chosenAt, 40) || Number.isNaN(Date.parse(p.chosenAt)) || p.via !== 'chip') continue;
2597
+ || !citeText(p.chosenBy, 200) || !citeText(p.chosenAt, 40) || Number.isNaN(Date.parse(p.chosenAt)) || p.via !== 'chip') return;
2538
2598
  const source = chosenSourceOf(p.source);
2539
2599
  const basis = goneBasisOf(p.basis);
2540
- if (!source || basis === null) continue;
2541
- if (!claimHeld(p.citationId, turnId, p.anchor) || !basisHeld({ citationId: p.citationId, anchor: p.anchor, basis }, turnId)) continue;
2600
+ if (!source || basis === null) return;
2601
+ if (!claimHeld(p.citationId, turnId, p.anchor) || !basisHeld({ citationId: p.citationId, anchor: p.anchor, basis }, turnId)) return;
2542
2602
  const made = out.get(p.anchor) ?? [];
2543
- made.push({ eventId: event.eventId, anchor: p.anchor, citationId: p.citationId, chosenBy: p.chosenBy, chosenAt: p.chosenAt, source, ...(basis ? { basis } : {}) });
2603
+ const choice = { eventId: event.eventId, anchor: p.anchor, citationId: p.citationId, chosenBy: p.chosenBy, chosenAt: p.chosenAt, source, ...(basis ? { basis } : {}) };
2604
+ made.push(choice);
2605
+ byId.set(String(event.eventId).toLowerCase(), choice);
2544
2606
  out.set(p.anchor, made);
2545
- }
2607
+ });
2546
2608
  return out;
2547
2609
  }
2548
2610
 
2611
+ /**
2612
+ * #3100: the source a person chose that an assumption on its chosen source found gone names, as `chosenGone`: undefined
2613
+ * when there is none, null when one is there but is not what the route writes (`normalizeChosenGone`).
2614
+ */
2615
+ function chosenGoneOf(value) {
2616
+ if (value === undefined) return undefined;
2617
+ if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some((key) => !['choiceId', 'state', 'checkedAt'].includes(key))) return null;
2618
+ if (typeof value.choiceId !== 'string' || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.choiceId)
2619
+ || !GONE_SOURCE_STATES.includes(value.state) || typeof value.checkedAt !== 'string' || value.checkedAt.length > 40 || Number.isNaN(Date.parse(value.checkedAt))) return null;
2620
+ return { choiceId: value.choiceId.toLowerCase(), state: value.state, checkedAt: value.checkedAt };
2621
+ }
2622
+
2623
+ /** An assumption row as `normalizeCitationAssumption` reads it, for this turn: its basis and chosen-gone basis, or null. */
2624
+ function assumptionRecordOf(event, turnId) {
2625
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2626
+ const p = event.payload || {};
2627
+ if (p.turnId !== turnId || typeof p.turnId !== 'string' || !uuid.test(p.turnId) || typeof p.citationId !== 'string' || !uuid.test(p.citationId)
2628
+ || typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || !(p.claim === null || citeText(p.claim, 300))
2629
+ || !citeText(p.assumedBy, 200) || !citeText(p.assumedAt, 40) || Number.isNaN(Date.parse(p.assumedAt)) || p.via !== 'chip') return null;
2630
+ const basis = goneBasisOf(p.basis);
2631
+ const chosenGone = chosenGoneOf(p.chosenGone);
2632
+ if (basis === null || chosenGone === null) return null;
2633
+ return { basis, chosenGone };
2634
+ }
2635
+
2549
2636
  function citeText(x, max) { return typeof x === 'string' && x.length > 0 && x.length <= max && !/[\u0000-\u001F\u007F]/.test(x); }
2550
2637
 
2551
2638
  /**
@@ -2598,26 +2685,32 @@
2598
2685
  * #2642: the person's "go on with this as an assumption" on this answer's claims — the server's validity rule
2599
2686
  * (`liveCitationAssumptions`): what it names holds the claim (`claimHeld`); the first record per claim wins. #3017: one
2600
2687
  * per claim with no source, and one per claim and citation decided on a cited source found gone; which of them is live
2601
- * is `decisionLiveOn`, decided where the claim's current entry is known (`citationIndex`).
2688
+ * is `decisionLiveOn`, decided where the claim's current entry is known (`citationIndex`). #3100: and one per claim and
2689
+ * the earlier choice of it, on the same citation, whose chosen source FloLess found gone (`chosenGone`).
2602
2690
  */
2603
2691
  function citationAssumptions(turnId) {
2604
2692
  const out = new Map();
2605
2693
  if (!turnId) return [];
2606
- const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2607
- const text = (x, max) => typeof x === 'string' && x.length > 0 && x.length <= max && !/[\u0000-\u001F\u007F]/.test(x);
2694
+ const choices = [...citationChoices(turnId).values()].flat();
2695
+ const seenIds = new Set();
2608
2696
  for (const event of state.events) {
2697
+ if (event.type === 'citation-choice') { seenIds.add(String(event.eventId).toLowerCase()); continue; }
2609
2698
  if (event.type !== 'citation-assumption') continue;
2610
2699
  const p = event.payload || {};
2611
2700
  // Every check `normalizeCitationAssumption` makes: a row the server would not tell the AI about is never shown as one.
2612
- if (p.turnId !== turnId || typeof p.turnId !== 'string' || !uuid.test(p.turnId) || typeof p.citationId !== 'string' || !uuid.test(p.citationId)
2613
- || typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || !(p.claim === null || text(p.claim, 300))
2614
- || !text(p.assumedBy, 200) || !text(p.assumedAt, 40) || Number.isNaN(Date.parse(p.assumedAt)) || p.via !== 'chip') continue;
2615
- const basis = goneBasisOf(p.basis);
2616
- const slot = basis ? `${p.anchor}\u0000${p.citationId.toLowerCase()}` : p.anchor;
2617
- if (basis === null || out.has(slot)) continue;
2701
+ const read = assumptionRecordOf(event, turnId);
2702
+ if (!read) continue;
2703
+ const { basis, chosenGone } = read;
2704
+ // #3100: one per claim and the choice it supersedes, which must be an earlier choice of this claim, on this citation.
2705
+ const slot = chosenGone ? `${p.anchor}\u0000chosen\u0000${chosenGone.choiceId}` : basis ? `${p.anchor}\u0000${p.citationId.toLowerCase()}` : p.anchor;
2706
+ if (out.has(slot)) continue;
2618
2707
  if (!claimHeld(p.citationId, turnId, p.anchor) || !basisHeld({ citationId: p.citationId, anchor: p.anchor, basis }, turnId)) continue;
2708
+ const choice = chosenGone && seenIds.has(chosenGone.choiceId) ? choices.find((made) => String(made.eventId).toLowerCase() === chosenGone.choiceId
2709
+ && made.anchor === p.anchor && made.citationId.toLowerCase() === p.citationId.toLowerCase()) : null;
2710
+ if (chosenGone && !choice) continue;
2619
2711
  // #3000: the claim's own words are kept with it, so the record always says which claim it is about.
2620
- out.set(slot, { anchor: p.anchor, citationId: p.citationId, claim: p.claim, assumedBy: p.assumedBy, assumedAt: p.assumedAt, ...(basis ? { basis } : {}) });
2712
+ out.set(slot, { anchor: p.anchor, citationId: p.citationId, claim: p.claim, assumedBy: p.assumedBy, assumedAt: p.assumedAt, ...(basis ? { basis } : {}),
2713
+ ...(chosenGone ? { chosenGone, choice } : {}) });
2621
2714
  }
2622
2715
  return [...out.values()];
2623
2716
  }
@@ -2691,18 +2784,25 @@
2691
2784
  }
2692
2785
  return entry.read === 'sent' ? 'not recorded, it went with your question' : 'not recorded';
2693
2786
  }
2787
+ const tile = citedTile(entry);
2788
+ if (tile) return `yes, only its ${TILE_PLACES[tile]} part, enlarged`;
2694
2789
  return CITATION_READ[entry.read] || CITATION_READ.no;
2695
2790
  }
2696
2791
 
2697
- function citationProvenance(entry) {
2698
- // #2643: a source the person chose says who chose it, and claims no AI read: the choice records none.
2699
- if (entry.chosen) return `Found: yes · Chosen by ${assumedWho({ assumedBy: entry.chosen.chosenBy })}, ${assumedWhen({ assumedAt: entry.chosen.chosenAt })} · Read by AI: this choice records none · Checked: no`;
2792
+ function citationProvenance(entry, seen) {
2793
+ // #2643: a source the person chose says who chose it, and claims no AI read: the choice records none. #3039: and where
2794
+ // it stands now, when FloLess found it changed or gone since it was chosen.
2795
+ if (entry.chosen) {
2796
+ const found = CHOSEN_FOUND[seen] ? `${CHOSEN_FOUND[seen]} ${chosenSince(entry.chosen, seen)}` : 'Found: yes';
2797
+ return `${found} · Chosen by ${assumedWho({ assumedBy: entry.chosen.chosenBy })}, ${assumedWhen({ assumedAt: entry.chosen.chosenAt })} · Read by AI: this choice records none · Checked: no`;
2798
+ }
2700
2799
  return `Found: yes · Read by AI: ${citationReadWords(entry)} · Checked: no`;
2701
2800
  }
2702
2801
 
2703
2802
  /** The chip's tag, in words: never a colour or a tick. */
2704
- function citationMarks(entry) {
2705
- if (entry.chosen) return `FOUND · CHOSEN BY ${assumedWho({ assumedBy: entry.chosen.chosenBy }).toUpperCase()}`;
2803
+ function citationMarks(entry, seen) {
2804
+ // #3039: a chosen source's state takes FOUND's place, in the words every chip uses; who chose it stays.
2805
+ if (entry.chosen) return `${CHOSEN_FOUND[seen] ? SOURCE_MARKS[seen] : 'FOUND'} · CHOSEN BY ${assumedWho({ assumedBy: entry.chosen.chosenBy }).toUpperCase()}`;
2706
2806
  if (entry.kind === 'attachment' && entry.read === 'sent') return 'FOUND · SENT WITH QUESTION';
2707
2807
  return ['whole-sheet', 'tiles', 'yes', 'mentioned', 'looked', 'in-message'].includes(entry.read) ? 'FOUND · READ BY AI' : 'FOUND';
2708
2808
  }
@@ -2900,11 +3000,13 @@
2900
3000
  const assumed = !sourced && row?.assumptionLive ? row.assumption : null;
2901
3001
  // #2930: the AI named a member that exists the wrong way: its reference to correct, not a claim without a source.
2902
3002
  const misnamed = !sourced && !assumed && referenceProblem(row?.entry);
2903
- const label = resolved ? citationLabel(row.entry) : chosen ? citationLabel(chosenViewRow(row, chosen).entry) : assumed ? 'assumption, no source'
3003
+ // #3100: an assumption made after the source the person chose was found gone had a source: it is never "no source".
3004
+ const goneChosen = assumed?.chosenGone ? `The source ${assumedWho({ assumedBy: assumed.choice.chosenBy })} chose, ${citationLabel(assumed.choice.source)}, ${GONE_SAID[assumed.chosenGone.state]} when FloLess checked` : '';
3005
+ const label = resolved ? citationLabel(row.entry) : chosen ? citationLabel(chosenViewRow(row, chosen).entry) : goneChosen ? 'assumption' : assumed ? 'assumption, no source'
2904
3006
  : misnamed ? 'source needs correcting' : 'no source';
2905
3007
  // No citation for this anchor on this page is "none recorded", not "none found": the AI may have given none, or the
2906
3008
  // record has not reached this page yet.
2907
- const missing = assumed ? `${assumed.basis ? `The cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked` : 'No source'}. Assumed by ${assumedWho(assumed)} on ${assumedWhen(assumed)}`
3009
+ const missing = assumed ? `${goneChosen || (assumed.basis ? `The cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked` : 'No source')}. Assumed by ${assumedWho(assumed)} on ${assumedWhen(assumed)}`
2908
3010
  : misnamed === 'kb-source' ? (row.entry.match === 'bytes' ? 'Source needs correcting: the file is in Knowledge, but the AI cited FloLess’s copy of it'
2909
3011
  : 'Source needs correcting: the AI cited FloLess’s copy of a file that may be one of the reference files in Knowledge')
2910
3012
  : misnamed ? 'Source needs correcting: the member exists, but the AI named it wrongly'
@@ -2929,7 +3031,7 @@
2929
3031
  const tag = document.createElement('span'); tag.className = 'ai-chat-assume by-person';
2930
3032
  tag.textContent = 'Assumption';
2931
3033
  tag.dataset.tip = `${assumedWho(assumed) === 'you' ? 'You' : assumedWho(assumed)} recorded this as an assumption (${assumedWhen(assumed)}). `
2932
- + (assumed.basis ? `Its cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked.` : 'It has no source.');
3034
+ + (goneChosen ? `${goneChosen}.` : assumed.basis ? `Its cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked.` : 'It has no source.');
2933
3035
  marker.after(tag);
2934
3036
  }
2935
3037
  }
@@ -3099,6 +3201,8 @@
3099
3201
  number.textContent = row.number ? String(row.number) : '?';
3100
3202
  chip.append(number);
3101
3203
  if (row.choice) return chosenChip(chip, turnId, row);
3204
+ // #3100: the person went on with a claim whose CHOSEN source FloLess found gone.
3205
+ if (row.assumptionLive && row.assumption.chosenGone) return chosenGoneAssumedChip(chip, turnId, row, number);
3102
3206
  const entry = row.entry;
3103
3207
  // #3017: the person went on with a claim whose cited source FloLess found gone.
3104
3208
  if (entry.status === 'resolved' && row.assumptionLive) return goneAssumedChip(chip, turnId, row, number);
@@ -3291,6 +3395,45 @@
3291
3395
  return chip;
3292
3396
  }
3293
3397
 
3398
+ /**
3399
+ * #3100: the person's assumption on a claim whose source THEY had chosen, after FloLess found that source gone. Still
3400
+ * "?": an assumption is not a source. It names the source they chose and what FloLess found when it looked, never that
3401
+ * the claim had no source; the choice stays on record as made, and its source still opens (it may be back).
3402
+ */
3403
+ function chosenGoneAssumedChip(chip, turnId, row, number) {
3404
+ const record = row.assumption;
3405
+ const choice = record.choice;
3406
+ const who = assumedWho({ assumedBy: choice.chosenBy });
3407
+ const said = `The source ${who === 'you' ? 'you' : who} chose, ${citationLabel(choice.source)}, ${GONE_SAID[record.chosenGone.state]} when FloLess checked`;
3408
+ chip.classList.add('assumed', 'gone');
3409
+ // #3100: the source on record is one a person chose, so the row never says the AI gave it, or that there was none.
3410
+ chip.dataset.chosenGone = 'true';
3411
+ number.setAttribute('aria-label', `Assumption. ${said}`);
3412
+ const why = document.createElement('span'); why.className = 'ai-chat-source-why';
3413
+ why.textContent = `Assumed by ${assumedWho(record)}, ${assumedWhen(record)}. ${said}.`;
3414
+ const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
3415
+ marks.textContent = 'ASSUMPTION';
3416
+ marks.dataset.tip = 'Your decision to go on without the source you chose. The choice stays on record as it was made. Nothing checked this claim. The AI is reminded of it with each message you send';
3417
+ const label = citationLabel(choice.source);
3418
+ const open = button('Open the source you chose', 'shell.chat-cite-open-chosen', 'ai-chat-source-action quiet');
3419
+ open.dataset.commandInstanceLabel = label;
3420
+ open.setAttribute('aria-label', `Open the source you chose: ${label}`);
3421
+ open.dataset.tip = `What was chosen: ${label}`;
3422
+ open.addEventListener('click', () => openCitedSource(chosenViewRow(row, choice), turnId));
3423
+ const choose = button('Choose a source…', 'shell.chat-cite-choose', 'ai-chat-source-action quiet');
3424
+ choose.dataset.commandInstanceLabel = label;
3425
+ choose.setAttribute('aria-label', 'Choose a source for this claim');
3426
+ choose.setAttribute('aria-haspopup', 'dialog');
3427
+ choose.dataset.tip = 'Pick the sheet, model member, Knowledge page or attached file this claim comes from. It is recorded as chosen by you, with the date; nothing checks the claim';
3428
+ choose.addEventListener('click', () => openSourcePicker(row, turnId, null));
3429
+ const claimed = record.claim ? claimCited(`“${record.claim}”`, 'The claim you recorded as an assumption') : null;
3430
+ // A choice made after the AI's cited source was found gone keeps that cited source to open, as its chip did.
3431
+ chip.append(...(claimed ? [claimed] : []), why, marks, sourceActions(open, choose, ...(record.basis ? [citedSourceOpener(turnId, row)] : [])));
3432
+ const saved = citationNote(row, turnId);
3433
+ if (saved) chip.append(saved);
3434
+ return chip;
3435
+ }
3436
+
3294
3437
  /** The person's ways on from a claim with no source, in one row that wraps between buttons, never inside one. */
3295
3438
  function sourceActions(...buttons) {
3296
3439
  const actions = document.createElement('span'); actions.className = 'ai-chat-source-actions';
@@ -3305,7 +3448,12 @@
3305
3448
  function chosenChip(chip, turnId, row) {
3306
3449
  const view = chosenViewRow(row, row.choice);
3307
3450
  const entry = view.entry;
3451
+ // #3039: where the chosen source stands now, as FloLess last found it (the answer's check or its viewer). The choice
3452
+ // itself is unchanged: only its state is shown.
3453
+ const seen = CHOSEN_FOUND[seenSource(view)] ? seenSource(view) : undefined;
3454
+ const gone = GONE_SOURCE_STATES.includes(seen);
3308
3455
  chip.classList.add('chosen');
3456
+ chip.classList.toggle('stale', gone);
3309
3457
  if (entry.kind === 'sheet') {
3310
3458
  const thumb = document.createElement('img'); thumb.alt = ''; thumb.loading = 'lazy';
3311
3459
  // Only the picture FloLess held when it was chosen, byte for byte (never a render); a changed picture has none.
@@ -3320,22 +3468,37 @@
3320
3468
  const label = citationLabel(entry);
3321
3469
  const open = button(label, 'shell.chat-cite-open-chosen', 'ai-chat-answer-open ai-chat-source-open');
3322
3470
  open.dataset.commandInstanceLabel = label;
3323
- open.setAttribute('aria-label', `Open ${label}`);
3324
- open.dataset.tip = citationProvenance(entry);
3471
+ open.setAttribute('aria-label', `Open ${label}${seen ? `, ${chosenSince(row.choice, seen)}` : ''}`);
3472
+ open.dataset.tip = citationProvenance(entry, seen);
3325
3473
  open.addEventListener('click', () => openCitedSource(view, turnId));
3326
3474
  const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
3327
- marks.textContent = citationMarks(entry);
3328
- marks.dataset.tip = 'A person picked this source. No AI read is recorded for this choice, and nothing checked the claim';
3329
- const change = button('Change…', 'shell.chat-cite-change', 'ai-chat-source-action quiet');
3475
+ marks.textContent = citationMarks(entry, seen);
3476
+ marks.dataset.tip = gone ? 'A person picked this source. When FloLess checked, it was gone; the choice stays as it was made'
3477
+ : 'A person picked this source. No AI read is recorded for this choice, and nothing checked the claim';
3478
+ // A gone source makes Change… the way on.
3479
+ const change = button('Change…', 'shell.chat-cite-change', `ai-chat-source-action${gone ? '' : ' quiet'}`);
3330
3480
  change.setAttribute('aria-label', 'Change the source for this claim');
3331
3481
  change.setAttribute('aria-haspopup', 'dialog');
3332
3482
  change.dataset.tip = 'Pick a different source. The earlier choice stays in the record';
3333
3483
  change.addEventListener('click', () => openSourcePicker(row, turnId, row.choice.eventId));
3484
+ // #3100: a gone chosen source may also be gone on from as an assumption, as a gone cited one may. FloLess checks the
3485
+ // chosen source again before it records it; the choice stays on record.
3486
+ let assume = null;
3487
+ if (gone) {
3488
+ assume = button(ASSUME_LABEL, 'shell.chat-cite-assume', 'ai-chat-source-action quiet');
3489
+ assume.dataset.commandInstanceLabel = label;
3490
+ assume.setAttribute('aria-label', `${ASSUME_LABEL}: the claim whose chosen source, ${label}, is gone`);
3491
+ assume.dataset.tip = 'Saves your decision with your name and the date, and labels the claim Assumption. The source you chose stays on record. Nothing runs now: the AI receives it with your next message';
3492
+ assume.addEventListener('click', () => assumeClaim(row, turnId, assume.closest('.ai-chat-source'), assume, null, row.choice));
3493
+ }
3334
3494
  // #3017: chosen after FloLess found the cited source gone: what it found and when, and the cited source to open.
3335
3495
  const basis = row.choice.basis;
3336
- chip.append(open, marks, basis ? sourceActions(change, citedSourceOpener(turnId, row)) : change);
3496
+ const ways = [change, ...(assume ? [assume] : []), ...(basis ? [citedSourceOpener(turnId, row)] : [])];
3497
+ chip.append(open, marks, ways.length > 1 ? sourceActions(...ways) : change);
3337
3498
  const earlier = row.choices.length > 1 ? row.choices[row.choices.length - 2] : null;
3338
- const before = [basis ? `The cited source ${citationLabel(row.entry)} ${GONE_SAID[basis.state]} when FloLess checked` : '',
3499
+ const said = gone ? chosenSince(row.choice, seen) : '';
3500
+ const before = [said ? `${said[0].toUpperCase()}${said.slice(1)}. The choice stays on record` : '',
3501
+ basis ? `The cited source ${citationLabel(row.entry)} ${GONE_SAID[basis.state]} when FloLess checked` : '',
3339
3502
  row.assumption ? `Earlier assumed by ${assumedWho(row.assumption)}, ${assumedWhen(row.assumption)}` : '',
3340
3503
  earlier ? `Changed from ${earlier.source.label}` : ''].filter(Boolean);
3341
3504
  if (before.length) {
@@ -3351,24 +3514,28 @@
3351
3514
  * the server writes it with the signed-in account and the date. The conversation is the one the chip was painted for:
3352
3515
  * a reply that lands after the person moved to another conversation changes nothing on screen.
3353
3516
  */
3354
- async function assumeClaim(row, turnId, chip, assume, goneIndex = null) {
3517
+ async function assumeClaim(row, turnId, chip, assume, goneIndex = null, goneChoice = null) {
3355
3518
  if (assume.getAttribute('aria-busy') === 'true' || !row.chatId) return;
3356
3519
  chip.querySelector('.ai-chat-source-note')?.remove();
3357
3520
  // Busy, not disabled: a disabled button drops the keyboard focus to the page.
3358
3521
  assume.setAttribute('aria-busy', 'true'); assume.setAttribute('aria-disabled', 'true');
3359
3522
  assume.textContent = 'Saving…';
3360
3523
  const claim = unsourcedClaimWords(turnId, row.anchor);
3361
- let saved = null; let problem = '';
3524
+ let saved = null; let problem = ''; let lastError = '';
3362
3525
  try {
3363
- const result = await request(`/api/chat/conversations/${encodeURIComponent(row.chatId)}/citations/${encodeURIComponent(row.citationId)}/assume`, {
3526
+ // #3100: on a chosen source found gone, the claim is the one the choice holds, and the choice is named.
3527
+ const citationId = goneChoice ? goneChoice.citationId : row.citationId;
3528
+ const result = await request(`/api/chat/conversations/${encodeURIComponent(row.chatId)}/citations/${encodeURIComponent(citationId)}/assume`, {
3364
3529
  method: 'POST', body: JSON.stringify({ owner: row.ownerObject, turnId, anchor: row.anchor, claim: claim || null,
3365
3530
  // #3017: a claim the AI cited, whose source FloLess found gone: FloLess checks that again before recording.
3366
- ...(goneIndex === null ? {} : { sourceGone: { index: goneIndex } }) }),
3531
+ ...(goneIndex === null ? {} : { sourceGone: { index: goneIndex } }),
3532
+ ...(goneChoice ? { chosenGone: { choiceId: goneChoice.eventId } } : {}) }),
3367
3533
  });
3368
3534
  saved = result?.event ?? null;
3369
3535
  } catch (error) {
3536
+ lastError = error?.code ?? '';
3370
3537
  // The server's own sentence when it says why nothing was recorded; anything else is a plain "try again".
3371
- problem = ['chat-cite-assume-stale', 'chat-cite-assume-unknown', 'chat-cite-assume-unreadable', 'chat-cite-assume-source-there'].includes(error?.code)
3538
+ problem =['chat-cite-assume-stale', 'chat-cite-assume-unknown', 'chat-cite-assume-unreadable', 'chat-cite-assume-source-there'].includes(error?.code)
3372
3539
  ? String(error.message) : 'Could not save your choice. Try again.';
3373
3540
  }
3374
3541
  if (state.chat?.chatId !== row.chatId) return;
@@ -3380,7 +3547,8 @@
3380
3547
  const after = [...ui.feed.querySelectorAll('.ai-chat-source')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === row.anchor);
3381
3548
  after?.querySelector('[data-command-id="shell.chat-cite-ask"], [data-command-id="shell.chat-cite-choose"]')?.focus({ preventScroll: true });
3382
3549
  const record = citationIndex(turnId).byAnchor.get(row.anchor)?.assumption;
3383
- announce(record ? `Marked as an assumption by ${assumedWho(record)}, ${assumedWhen(record)}. No source.` : 'Your choice was saved.');
3550
+ // #3100: a claim whose chosen source was found gone had a source; it is never announced as having none.
3551
+ announce(record ? `Marked as an assumption by ${assumedWho(record)}, ${assumedWhen(record)}. ${record.chosenGone ? 'The source you chose stays on record.' : 'No source.'}` : 'Your choice was saved.');
3384
3552
  return;
3385
3553
  }
3386
3554
  assume.removeAttribute('aria-busy'); assume.removeAttribute('aria-disabled');
@@ -3388,6 +3556,13 @@
3388
3556
  const note = document.createElement('span'); note.className = 'ai-chat-source-note warn'; note.setAttribute('role', 'status');
3389
3557
  note.textContent = problem;
3390
3558
  chip.append(note);
3559
+ // #3100: FloLess found the source the person chose there after all: the chip asks again where it stands, so it no
3560
+ // longer reads REMOVED beside a button that would be refused again. The reason is said aloud, as the repaint drops it.
3561
+ if (goneChoice && lastError === 'chat-cite-assume-source-there') {
3562
+ announce(problem);
3563
+ probedTurns.delete(`${row.chatId}\u0000${turnId}`);
3564
+ probeSources(turnId, citationIndex(turnId));
3565
+ }
3391
3566
  }
3392
3567
 
3393
3568
  /** #2692: what the picker can list, in order: the project's drawings and model, its Knowledge, and this conversation's files. */
@@ -3865,7 +4040,7 @@
3865
4040
  }
3866
4041
  const head = document.createElement('span'); head.className = 'ai-chat-sources-head';
3867
4042
  // #2643: a source a person chose is not one the AI gave, so a row holding one says neither.
3868
- const chosen = chips.some((chip) => chip.classList.contains('chosen'));
4043
+ const chosen = chips.some((chip) => chip.classList.contains('chosen') || chip.dataset.chosenGone === 'true');
3869
4044
  // #2999: a row of claims the AI named no source for says so, never that the AI gave sources.
3870
4045
  const none = !chosen && chips.every((chip) => chip.dataset.bare === 'true');
3871
4046
  head.textContent = none ? 'Claims with no source' : chosen ? 'Sources for this answer' : 'Sources the AI gave for this answer';
@@ -4104,6 +4279,8 @@
4104
4279
  // Closing is done here, not left to the dialog's own `close` event, which an embedding browser may never fire: the
4105
4280
  // viewer is removed, its picture released and focus handed back to the chip, once, whichever way it closes.
4106
4281
  let picture = null;
4282
+ // #3018: a PDF drawn by FloLess's own viewer, whose worker and pages are released when the viewer closes.
4283
+ let pdfView = null;
4107
4284
  let finished = false;
4108
4285
  const controller = new AbortController();
4109
4286
  let loadingTimer = null;
@@ -4116,6 +4293,7 @@
4116
4293
  if (dialog.open) dialog.close();
4117
4294
  hide();
4118
4295
  if (picture) URL.revokeObjectURL(picture);
4296
+ pdfView?.destroy();
4119
4297
  liveCitationOpener(turnId, row.anchor)?.focus({ preventScroll: true });
4120
4298
  };
4121
4299
  close.addEventListener('click', finish);
@@ -4125,7 +4303,8 @@
4125
4303
  // #3017: what this open found, for the chip and for this line, which never says "Found: yes" over a source found gone.
4126
4304
  const found = (seen) => {
4127
4305
  viewerFound(row, turnId, seen);
4128
- if (!entry.chosen && SOURCE_FOUND[seen]) note.textContent = `${SOURCE_FOUND[seen]} · Read by AI: ${citationReadWords(entry)} · Checked: no`;
4306
+ if (entry.chosen) { if (CHOSEN_FOUND[seen] || seen === 'same') note.textContent = citationProvenance(entry, seen); }
4307
+ else if (SOURCE_FOUND[seen]) note.textContent = `${SOURCE_FOUND[seen]} · Read by AI: ${citationReadWords(entry)} · Checked: no`;
4129
4308
  };
4130
4309
  const body = document.createElement('div'); body.className = 'ai-chat-source-viewer-body';
4131
4310
  const status = Object.assign(document.createElement('p'), { className: 'ai-chat-source-viewer-status', textContent: 'Opening…' });
@@ -4155,7 +4334,12 @@
4155
4334
  dialog.append(again);
4156
4335
  };
4157
4336
  const refused = async (response) => {
4158
- if (response.status === 404) return 'FloLess no longer holds this source, or its project is no longer part of this conversation.';
4337
+ if (response.status === 404) {
4338
+ // #3041: a file the server says was removed is said as removed; any other 404 stays the plain "not here".
4339
+ const said = entry.kind === 'attachment' ? await response.json().catch(() => null) : null;
4340
+ return said?.code === 'citation-source-removed' && typeof said.message === 'string' && said.message ? said.message
4341
+ : 'FloLess no longer holds this source, or its project is no longer part of this conversation.';
4342
+ }
4159
4343
  if (response.status === 410) {
4160
4344
  // #2692: a chosen source says it changed since the person chose it, never since an answer cited it.
4161
4345
  if (entry.kind !== 'attachment') {
@@ -4194,6 +4378,8 @@
4194
4378
  const response = await fetch(citationUrl(row, 'image'), { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
4195
4379
  if (!response.ok) { const why = await refused(response); if (!finished) { status.textContent = why; retry(); } return; }
4196
4380
  const shown = response.headers.get('X-FloLess-Shown') || 'as-seen';
4381
+ // #3038: the picture the AI was shown, or established as no longer the stored one; tiles or unchecked say nothing.
4382
+ found({ 'as-seen': 'same', 'from-source:changed': 'changed', 'from-source:missing': 'changed' }[shown] ?? null);
4197
4383
  const bytes = await response.blob();
4198
4384
  // Checked after every wait: a viewer closed meanwhile creates nothing it would never release.
4199
4385
  if (finished) return;
@@ -4201,11 +4387,13 @@
4201
4387
  const image = Object.assign(document.createElement('img'), { src: picture, alt: `${entry.label}${shown === 'as-seen' ? '' : ', rendered from the source drawing'}` });
4202
4388
  if (!await mountDrawing().setImage(image, () => !finished, true)) return;
4203
4389
  loaded();
4204
- status.textContent = SHOWN[shown] || SHOWN['as-seen'];
4390
+ const tile = shown === 'from-source:tiles' && !entry.chosen ? citedTile(entry) : 0;
4391
+ status.textContent = tile ? `The whole sheet, rendered from its source drawing. The AI saw only its ${TILE_PLACES[tile]} part, enlarged.`
4392
+ : SHOWN[shown] || SHOWN['as-seen'];
4205
4393
  return;
4206
4394
  }
4207
4395
  if (entry.kind === 'member') { await showCitedMember(row, { dialog, body, status, finish, refused, done: () => finished, found }); return; }
4208
- if (entry.kind === 'kb-source') { await showCitedKnowledgeFile(row, { body, status, refused, retry, signal: controller.signal, done: () => finished, picture: (url) => { picture = url; }, mountDrawing, loaded, stale: (state) => {
4396
+ if (entry.kind === 'kb-source') { await showCitedKnowledgeFile(row, { body, status, refused, retry, signal: controller.signal, done: () => finished, picture: (url) => { picture = url; }, pdf: (handle) => { pdfView = handle; }, mountDrawing, loaded, stale: (state) => {
4209
4397
  // The viewer's own provenance line says it too: it must not still say "Found: yes" over a removed file.
4210
4398
  knowledgeFileStale(row, turnId, state);
4211
4399
  if (KNOWLEDGE_FILE_TIPS[state]) note.textContent = KNOWLEDGE_FILE_TIPS[state];
@@ -4234,9 +4422,12 @@
4234
4422
  if (entry.kind === 'attachment') {
4235
4423
  const response = await fetch(citationUrl(row, 'attachment'), { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
4236
4424
  // #3017: what this open found, for the chip: the attached file changed, or no longer the one attached.
4237
- // A 404 is said for a file gone and for one no longer as attached alike, so it tells the chip nothing.
4238
- found(response.ok ? 'same' : response.status !== 410 ? null
4239
- : await response.clone().json().then((said) => (said?.code === 'citation-source-not-as-attached' ? 'not-as-attached' : 'changed'), () => null));
4425
+ // #3041: a 404 tells the chip only when the server established the file was removed; a plain 404 tells it nothing.
4426
+ const said = response.ok ? null : await response.clone().json().catch(() => null);
4427
+ found(response.ok ? 'same'
4428
+ : response.status === 404 ? (said?.code === 'citation-source-removed' ? 'removed' : null)
4429
+ : response.status !== 410 || !said ? null
4430
+ : said.code === 'citation-source-not-as-attached' ? 'not-as-attached' : 'changed');
4240
4431
  if (!response.ok) { const why = await refused(response); if (!finished) { status.textContent = why; retry(); } return; }
4241
4432
  const type = (response.headers.get('Content-Type') || '').split(';')[0].trim().toLowerCase();
4242
4433
  if (type.startsWith('image/')) {
@@ -4278,6 +4469,7 @@
4278
4469
  const why = {
4279
4470
  'chat-page-closed': 'This conversation is no longer the one open here. Open it again, then press Open in its default app.',
4280
4471
  'citation-source-unavailable': 'FloLess no longer holds this file in this conversation, so there is nothing to open.',
4472
+ 'citation-source-removed': 'This file was removed from this conversation, so there is nothing to open. Attach it again if you still need it.',
4281
4473
  'citation-source-changed': entry.chosen ? 'This file has changed since you chose it, so FloLess does not open it as the file you chose.'
4282
4474
  : 'This file has changed since the answer cited it, so FloLess does not open it as the cited file.',
4283
4475
  'citation-source-not-as-attached': entry.chosen ? CHOSEN_NOT_AS_ATTACHED : 'This file is no longer the plain file that was attached, so FloLess does not open it as the cited file. Attach the file again if you still need it.',
@@ -4291,6 +4483,8 @@
4291
4483
  return;
4292
4484
  }
4293
4485
  const response = await fetch(citationUrl(row, 'page'), { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
4486
+ // #3038: the page as cited, or changed since; a 404 (gone, or no longer this conversation's) says nothing.
4487
+ found(response.ok ? 'same' : response.status === 410 ? 'changed' : null);
4294
4488
  if (!response.ok) { const why = await refused(response); if (!finished) { status.textContent = why; retry(); } return; }
4295
4489
  const { page } = await response.json();
4296
4490
  if (finished) return;
@@ -4363,17 +4557,17 @@
4363
4557
  return;
4364
4558
  }
4365
4559
  if (!bytes.ok) { const why = await refused(bytes); if (!done()) status.textContent = why; return; }
4366
- const blob = await bytes.blob();
4367
- if (done()) return;
4368
- const url = URL.createObjectURL(blob);
4369
- view.picture(url);
4370
4560
  if (mime === 'application/pdf') {
4371
- const frame = document.createElement('iframe');
4372
- frame.className = 'ai-chat-source-viewer-pdf';
4373
- frame.setAttribute('aria-label', `${name}, as it was cited`);
4374
- frame.src = url;
4375
- body.append(frame);
4561
+ // #3018: FloLess draws these same verified bytes itself, never the browser's viewer in a frame, and never refetches.
4562
+ const data = new Uint8Array(await bytes.arrayBuffer());
4563
+ if (done()) return;
4564
+ view.pdf(window.flolessPdfView.mount(body, { bytes: data, name }));
4565
+ view.loaded();
4376
4566
  } else {
4567
+ const blob = await bytes.blob();
4568
+ if (done()) return;
4569
+ const url = URL.createObjectURL(blob);
4570
+ view.picture(url);
4377
4571
  const image = Object.assign(document.createElement('img'), { src: url, alt: name });
4378
4572
  if (!await view.mountDrawing().setImage(image, () => !done(), true)) return;
4379
4573
  view.loaded();
@@ -4417,6 +4611,17 @@
4417
4611
  changed: 'changed after this answer', removed: 'removed after this answer', unavailable: 'not available from this conversation now',
4418
4612
  'not-as-attached': 'no longer the file that was attached',
4419
4613
  };
4614
+ /**
4615
+ * #3039: a chosen source, by the same states: what FloLess found since it was chosen, said of the source, never of the
4616
+ * choice (the record stands as made). `chosenSince` names who chose it, as its chip does.
4617
+ */
4618
+ const CHOSEN_FOUND = { changed: 'Found: yes, but', removed: 'Found: no,', unavailable: 'Found: no,', 'not-as-attached': 'Found: no,' };
4619
+ function chosenSince(choice, seen) {
4620
+ const who = assumedWho({ assumedBy: choice.chosenBy });
4621
+ const since = who === 'you' ? 'since you chose it' : `since ${who} chose it`;
4622
+ return seen === 'changed' ? `changed ${since}` : seen === 'removed' ? `removed ${since}`
4623
+ : seen === 'unavailable' ? 'not available from this conversation now' : 'no longer the file that was chosen';
4624
+ }
4420
4625
  /** #3017: a decided claim's cited source, as what FloLess found when it checked, never that it still is so. */
4421
4626
  const GONE_SAID = { removed: 'was removed', unavailable: 'could not be reached from this conversation', 'not-as-attached': 'was no longer the file that was attached' };
4422
4627
  const PROBE_STATES = new Set(['same', 'changed', 'removed', 'unavailable', 'not-as-attached']);
@@ -4466,11 +4671,14 @@
4466
4671
 
4467
4672
  /**
4468
4673
  * #3017: what the viewer of a cited project file, attachment or member found, kept for its chip as the Knowledge file's
4469
- * is. A source the person chose has no AI chip to mark.
4674
+ * is. #3039: a source the person chose too, under its own record; its chip is drawn again from that.
4470
4675
  */
4471
4676
  function viewerFound(row, turnId, seen) {
4472
- if (row.entry.chosen || (seen !== 'same' && !SOURCE_MARKS[seen])) return;
4677
+ if (seen !== 'same' && !SOURCE_MARKS[seen]) return;
4473
4678
  seeSource(knowledgeFileKey(row), seen, Date.now());
4679
+ // A chosen source's chip is drawn from its own record, which this finding is now kept under. The chip at this claim
4680
+ // may by now be another one (the AI cited the claim since), so a chosen viewer never marks a chip in place.
4681
+ if (row.entry.chosen) { paintEvents(); return; }
4474
4682
  const chip = sourceChip(turnId, row.anchor);
4475
4683
  const wasGone = !!chip?.classList.contains('stale');
4476
4684
  markSourceChip(chip, seen, row.entry);
@@ -4488,7 +4696,7 @@
4488
4696
  const chatId = state.chat?.chatId;
4489
4697
  if (!chatId || !turnId || answerRunning(turnId)) return;
4490
4698
  const key = `${chatId}\u0000${turnId}`;
4491
- if (probedTurns.has(key) || ![...index.byAnchor.values()].some((row) => row.entry.status === 'resolved' && !row.entry.bare)) return;
4699
+ if (probedTurns.has(key) || ![...index.byAnchor.values()].some((row) => (row.entry.status === 'resolved' && !row.entry.bare) || row.choice)) return;
4492
4700
  probedTurns.add(key);
4493
4701
  const at = Date.now();
4494
4702
  request(`/api/chat/conversations/${encodeURIComponent(chatId)}/turns/${encodeURIComponent(turnId)}/source-states?${ownerQuery()}`).then((result) => {
@@ -4909,7 +5117,7 @@
4909
5117
  for (const live of statuses) if (live?.id) state.requestCards.set(live.id, live);
4910
5118
  // Only an authoritative removal retires transient state; folding or a conversation repaint does not.
4911
5119
  for (const live of statuses) if (live?.id && live.found === false) requestCardUi.delete(live.id);
4912
- // A hidden card's line reads these on the conversation's next repaint (the chat poll, every 5 s).
5120
+ // A hidden card's line reads these on the conversation's next repaint: the chat poll repaints when one changed (#3095).
4913
5121
  for (const card of ui.feed.querySelectorAll('.ai-chat-request-card[data-request-id]')) paintRequestCard(card);
4914
5122
  }
4915
5123
 
@@ -6961,7 +7169,9 @@
6961
7169
  note: 'Opens New workflow with its name filled in. Nothing is built until you confirm there.' };
6962
7170
  // An Open card only shows a page: there is no next step to confirm.
6963
7171
  case 'open':
6964
- return guideText ? { ...guideText, note: 'This only opens the page. Nothing changes.' } : null;
7172
+ // #3082: an Open card for one project or workflow opens that, not a page.
7173
+ return guideText ? { ...guideText, note: move.project ? 'This only opens the project. Nothing changes.'
7174
+ : move.workflow ? 'This only opens the workflow. Nothing changes.' : 'This only opens the page. Nothing changes.' } : null;
6965
7175
  default:
6966
7176
  return guideText ? { ...guideText, note: 'Nothing happens until you confirm in the next step.' } : null;
6967
7177
  }
@@ -7430,12 +7640,18 @@
7430
7640
  let opened = false;
7431
7641
  // #2520: a screen that refuses in its own words (a connection no longer in the model) says that, not the generic line.
7432
7642
  let refused = '';
7643
+ let said = '';
7433
7644
  try {
7434
7645
  if (answer.outcome === 'screen') opened = await openActionScreen(answer.screen);
7435
7646
  else if (answer.move?.kind === 'create-workflow' && typeof window.flolessBridge?.newWorkflow === 'function') {
7436
7647
  opened = true;
7437
7648
  void window.flolessBridge.newWorkflow({ name: answer.move.name });
7438
- } else if (answer.move) opened = Boolean(await window.flolessGuide?.openFlow?.(answer.move));
7649
+ } else if (answer.move) {
7650
+ const outcome = await window.flolessGuide?.openFlow?.(answer.move);
7651
+ opened = Boolean(outcome);
7652
+ // #3082: a project that opened at another step than the card named says so.
7653
+ if (typeof outcome?.said === 'string' && outcome.said) { said = outcome.said; }
7654
+ }
7439
7655
  } catch (error) {
7440
7656
  if (error?.plain === true && error.message) refused = error.message;
7441
7657
  else console.warn('[assistant] a suggestion could not open its place:', error);
@@ -7447,8 +7663,9 @@
7447
7663
  entry.focus = 'status'; repaintAssistantCard(entry); return;
7448
7664
  }
7449
7665
  entry.fold = null;
7666
+ if (said) { entry.error = said; entry.focus = 'status'; }
7450
7667
  repaintAssistantCard(entry);
7451
- announce(`Opened: ${title}.`);
7668
+ announce(said || `Opened: ${title}.`);
7452
7669
  }
7453
7670
 
7454
7671
  /** The follow-up into a box that holds something else, as the person chose: below it, or instead of it. Never sends. */
@@ -7832,6 +8049,37 @@
7832
8049
  announce(`${kind.label} card expanded.`);
7833
8050
  }
7834
8051
 
8052
+ /**
8053
+ * #3095: the 5 s poll leaves an unchanged conversation as it is, yet every card in it keeps itself current, as the old
8054
+ * redraw on every poll did: each card is drawn again, which runs its own live reads (a height question's, a connection's,
8055
+ * an action's, a filter suggestion's). A folded card's line is updated where it is. A card that did not change is the
8056
+ * very same node, or one its renderer built anew that says exactly what the one on screen says (isEqualNode), and is
8057
+ * left where it is. Any other change (a card that changed, folded by itself once settled, came back, or is new) redraws
8058
+ * the conversation, whose redraw keeps the keyboard, the caret and the scroll where they were.
8059
+ */
8060
+ function refreshFeedCardsInPlace() {
8061
+ const shown = new Map([...ui.feed.querySelectorAll('[data-event-id]')].map((item) => [item.dataset.eventId, item]));
8062
+ let changed = false;
8063
+ for (const event of state.events) {
8064
+ if (!feedCardKind(event)) continue;
8065
+ const node = renderEvent(event);
8066
+ if (!node) continue;
8067
+ const id = event.eventId;
8068
+ const open = feedCardShells.get(id);
8069
+ if (open?.isConnected) {
8070
+ if (open.firstElementChild !== node && !open.firstElementChild?.isEqualNode(node)) changed = true;
8071
+ continue;
8072
+ }
8073
+ if (feedCardLines.get(id)?.isConnected) {
8074
+ if (feedCard(node, event) !== feedCardLines.get(id)) changed = true; // still folded: its line was updated in place
8075
+ continue;
8076
+ }
8077
+ const current = shown.get(id); // a card that comes as it is (a one-line row)
8078
+ if (current !== node && !current?.isEqualNode(node)) changed = true;
8079
+ }
8080
+ if (changed) paintEvents();
8081
+ }
8082
+
7835
8083
  function renderEvent(event) {
7836
8084
  if (event.type === 'height-question-state') { applyHeightQuestionState(event); return null; }
7837
8085
  if (event.type === 'user-message' && event.payload?.source === 'request' && event.payload?.filterAi) return renderFilterQuestion(event);
@@ -8109,13 +8357,41 @@
8109
8357
  const heightInModelValue = (mm, units) => (displayUnitsModule ? displayUnitsModule.formatElevation(mm, units) : `${Math.round(mm)} mm`);
8110
8358
  const heightInModelText = (snapshot, units) => {
8111
8359
  if (!snapshot) return '';
8112
- if (snapshot.state === 'unknown' || typeof snapshot.value !== 'number') return 'In the model when asked: no height.';
8360
+ if (snapshot.state === 'unknown' || typeof snapshot.value !== 'number') {
8361
+ const drawn = heightDrawnText(snapshot, units);
8362
+ return `In the model when asked: no height.${drawn ? ` ${drawn}` : ''}`;
8363
+ }
8113
8364
  const value = heightInModelValue(snapshot.value, units);
8114
8365
  const tail = snapshot.state === 'assumed' ? ' (placed, not from the drawings)' : snapshot.state === 'answered' ? ' (your earlier answer)'
8115
8366
  // #2521: chosen by the AI in a Quick model build. Said plainly, so the person never takes it for a drawn height.
8116
8367
  : snapshot.state === 'decided' ? ' (chosen by the AI in the Quick model, not from the drawings or you)' : '';
8117
- return `In the model when asked: ${value}${tail}.`;
8368
+ const drawn = heightDrawnText(snapshot, units);
8369
+ return `In the model when asked: ${value}${tail}.${drawn ? ` ${drawn}` : ''}`;
8118
8370
  };
8371
+ /*
8372
+ * #2628 slice B: what this read's drawings state for an existing member's end, beside the height the model holds. ONE
8373
+ * helper, through `heightInModelText`, for every surface a person answers on (the card, the tray, several together),
8374
+ * so none can show the held height without the drawings. The server decides `prior`; this only words it.
8375
+ */
8376
+ const HEIGHT_DRAWN_TOLERANCE_MM = 0.5; // drawn-height-conflict.ts OVER_DRAWING_TOLERANCE_MM
8377
+ function heightDrawnText(snapshot, units) {
8378
+ const drawn = snapshot?.drawn;
8379
+ if (!drawn) return '';
8380
+ if (drawn.state === 'unchecked') return 'FloLess has not checked this end against this read’s drawings.';
8381
+ if (drawn.state === 'none') return drawn.complete ? 'FloLess found no drawn height for this end in this read.' : 'FloLess could not read the drawn heights for this end.';
8382
+ const { low, high, observations } = drawn.stated;
8383
+ const lowText = heightInModelValue(low, units), highText = heightInModelValue(high, units);
8384
+ const range = `${lowText === highText ? lowText : `${lowText} to ${highText}`} (${observations} ${observations === 1 ? 'reading' : 'readings'})`;
8385
+ const held = typeof snapshot.value === 'number' ? snapshot.value : null;
8386
+ const differs = held !== null && (Math.abs(held - low) > HEIGHT_DRAWN_TOLERANCE_MM || Math.abs(held - high) > HEIGHT_DRAWN_TOLERANCE_MM);
8387
+ // UX review: say what the drawings differ from or match; "now" only where something did change since an answer.
8388
+ const said = drawn.prior === 'changed' ? `The drawings now give ${range}; they have changed since your earlier answer.`
8389
+ : drawn.prior === 'unrecorded' ? `The drawings now give ${range}. FloLess did not record which drawings you answered against, so they may have changed.`
8390
+ : drawn.prior === 'acknowledged' ? `The drawings give ${range}, the same drawings you answered against.`
8391
+ : held === null ? `The drawings give ${range}.`
8392
+ : differs ? `The drawings give ${range}, which differs from the model’s height.` : `The drawings give ${range}, matching the model’s height.`;
8393
+ return drawn.complete ? said : `${said} FloLess could not read every drawn height for this end, so others may exist.`;
8394
+ }
8119
8395
  const HEIGHT_PROPOSED_TEXT = 'Proposed in the review; the model changes only if you accept it there.';
8120
8396
  // The server's sentence, then what to do next when it names a step (a damaged record says to discard the read).
8121
8397
  const heightErrorText = (error, fallback) => {
@@ -8781,7 +9057,12 @@
8781
9057
  if (response.status === 410) text = 'no longer available';
8782
9058
  else if (!response.ok) {
8783
9059
  const body = (response.headers.get('content-type') || '').includes('application/json') ? await response.json().catch(() => null) : null;
8784
- text = body?.error ? `could not be shown: ${body.error}` : `could not be shown (FloLess answered ${response.status})`;
9060
+ // #3097: the server's own sentence when it wrote one; otherwise why and what to do, never the status number.
9061
+ if (!body?.error) console.warn('[chat] a recorded picture could not be shown', url, response.status);
9062
+ // The shared sentence's cause and next step; for an unexplained failure its "couldn’t tell why" is kept too.
9063
+ const parts = body?.error ? null : failureParts({ status: response.status, body: body || {} }, { action: 'show this picture', retrySafe: true });
9064
+ text = body?.error ? `could not be shown: ${body.error}`
9065
+ : `could not be shown${parts.kind === 'unexpected' ? ', and FloLess couldn’t tell why' : ''}. ${parts.detail}`;
8785
9066
  }
8786
9067
  } catch { text = 'could not be shown: FloLess did not answer. Make sure it is still running.'; }
8787
9068
  slot.textContent = text;
@@ -10542,6 +10823,7 @@
10542
10823
  }
10543
10824
 
10544
10825
  function paintEvents(options = {}) {
10826
+ state.feedDrawn = false; // #3095: until the end below, so a draw that throws part-way is drawn again by the next poll
10545
10827
  announceLiveResponseOnce();
10546
10828
  const focusedCommand = ui.feed.contains(document.activeElement)
10547
10829
  ? document.activeElement?.dataset?.commandId : null;
@@ -10554,6 +10836,9 @@
10554
10836
  const focusedChip = chipNode ? { turnId: chipNode.dataset.turnId, anchor: chipNode.dataset.anchor, command: focusedNode.dataset?.commandId || '' } : null;
10555
10837
  // #3001: an answer's control for its numbers with no marker is rebuilt with the answer: the keyboard stays on that answer's.
10556
10838
  const focusedUncited = focusedNode?.closest?.('.ai-chat-uncited-row')?.dataset.answerKey ?? null;
10839
+ // #3039: a message the person clicked (it takes focus to be read or explained) stays theirs when a late source check
10840
+ // repaints its answer: the keyboard stays on the same message, never dropped to the page.
10841
+ const focusedMessage = focusedNode?.matches?.('.ai-chat-message[data-event-id]') ? focusedNode.dataset.eventId : null;
10557
10842
  if (options.forceBottom) state.feedLeftEnd = false; // the person just sent: the end is where they are going
10558
10843
  const nearBottom = !state.feedLeftEnd && ui.feed.scrollHeight - ui.feed.scrollTop - ui.feed.clientHeight < 56;
10559
10844
  const scrollTop = ui.feed.scrollTop;
@@ -10706,6 +10991,10 @@
10706
10991
  // #2678: the card folded by itself (answered) under the keyboard: the keyboard stays with it, on its line.
10707
10992
  refocused = feedCardLines.get(focusedShell.feedCardId);
10708
10993
  refocused.focus({ preventScroll: true });
10994
+ } else if (focusedMessage) {
10995
+ refocused = [...ui.feed.querySelectorAll('.ai-chat-message[data-event-id]')].find((node) => node.dataset.eventId === focusedMessage) ?? null;
10996
+ if (refocused) refocused.focus({ preventScroll: true });
10997
+ else refocused = restoreFeedFocus(focusedCommand);
10709
10998
  } else refocused = restoreFeedFocus(focusedCommand);
10710
10999
  // #2643: an open "Choose a source…" list lives outside the feed, so a repaint keeps it (and what is typed in it); it
10711
11000
  // follows its claim's rebuilt chip, and closes with its conversation.
@@ -10734,6 +11023,7 @@
10734
11023
  }
10735
11024
  updateOffscreenActivity();
10736
11025
  });
11026
+ state.feedDrawn = true;
10737
11027
  }
10738
11028
 
10739
11029
  // The feed's empty state. Four cases, in the order they must win: a sign-in window FloLess
@@ -11010,12 +11300,16 @@
11010
11300
  // block, exactly as it will run (spacing kept, long tokens wrapped, a long one scrolls). Nothing else is split.
11011
11301
  const commandAt = approval.protectedCommand === true && !connector ? approval.summary.indexOf('\nCommand: ') : -1;
11012
11302
  if (commandAt >= 0) {
11013
- copy.textContent = approval.summary.slice(0, commandAt);
11303
+ // #2893: a newer server puts one "\nWhy: <which part matched, and why>" line before the command.
11304
+ const head = approval.summary.slice(0, commandAt);
11305
+ const matchedAt = head.indexOf('\nWhy: ');
11306
+ copy.textContent = matchedAt >= 0 ? head.slice(0, matchedAt) : head;
11014
11307
  // #2224 item 1: why it asks although actions may be approved for this request or conversation.
11015
11308
  const why = document.createElement('p');
11016
11309
  why.className = 'ai-chat-approval-note';
11017
- why.textContent = 'This command names, or could match, a workflow’s approved lock, record or conversations, so FloLess '
11018
- + 'asks every time, even when actions are approved for this request or conversation.';
11310
+ const always = 'FloLess asks every time, even when actions are approved for this request or conversation.';
11311
+ why.textContent = matchedAt >= 0 ? `${head.slice(matchedAt + '\nWhy: '.length)} ${always}`
11312
+ : `This command names, or could match, a workflow’s approved lock, record or conversations, so ${always}`;
11019
11313
  nodes.push(why);
11020
11314
  const block = document.createElement('pre');
11021
11315
  block.className = 'ai-chat-approval-cmd';
@@ -13501,7 +13795,8 @@
13501
13795
  if (generation !== state.scopeGeneration) return;
13502
13796
  state.chats = result.chats || [];
13503
13797
  state.unreadableChats = result.unreadableChats || []; noteMovedChats(result.movedChats);
13504
- seedReadCursors(state.chats, scope.owner);
13798
+ await seedReadCursors(state.chats, scope.owner);
13799
+ if (generation !== state.scopeGeneration) return;
13505
13800
  paintHistory(); paintUnread();
13506
13801
  // #2007: a scope may name the conversation it is for (an agent run's); otherwise the newest one opens.
13507
13802
  const wanted = scope.chatId && state.chats.some((chat) => chat.chatId === scope.chatId) ? scope.chatId : state.chats[0]?.chatId;
@@ -13537,7 +13832,7 @@
13537
13832
  // project was opened in this browser, or its units cannot be read: then the conversation suggests nothing.
13538
13833
  async function lastProjectUnits() {
13539
13834
  let projectId = null;
13540
- try { projectId = localStorage.getItem('floless:last-project'); } catch { /* private mode: no suggestion */ }
13835
+ try { projectId = window.flolessPrefs ? window.flolessPrefs.get('lastProject') : localStorage.getItem('floless:last-project'); } catch { /* private mode: no suggestion */ }
13541
13836
  if (!projectId) return null;
13542
13837
  try {
13543
13838
  const body = await request(`/api/projects/${encodeURIComponent(projectId)}/display-units`);
@@ -14131,6 +14426,10 @@
14131
14426
  if (code === 'scope-missing' && row?.integration === 'google-workspace') {
14132
14427
  return 'This account was connected without permission to read these files. In Integrations, tick the Drive file list on Google Workspace and click Reconnect.';
14133
14428
  }
14429
+ // #2466: a Microsoft sign-in made before FloLess asked for the chat reads.
14430
+ if (code === 'scope-missing' && row?.integration === 'microsoft-365') {
14431
+ return 'This Microsoft 365 account was signed in before FloLess asked for these permissions. Open Integrations and click Reconnect.';
14432
+ }
14134
14433
  if (Object.hasOwn(INTEGRATION_REASON_COPY, code)) return INTEGRATION_REASON_COPY[code];
14135
14434
  const raw = String(row?.reason || '');
14136
14435
  if (!raw) return 'This connected account is unavailable.';
@@ -16281,11 +16580,42 @@
16281
16580
  }
16282
16581
  await recheckManagedCopy(scope, generation);
16283
16582
  if (!sameScope(scope, generation)) return;
16284
- if (state.chat) { paintSettings(); paintRecovery(); paintApproval(); paintEvents(); updateSendState(); }
16583
+ if (state.chat) {
16584
+ paintSettings(); paintRecovery(); paintApproval();
16585
+ // #3095: the feed is rebuilt only when something it draws from changed since the last poll; otherwise every
16586
+ // node the person is reading, pointing at or has selected stays, and only the cards' own live reads run.
16587
+ const feedKey = feedPollKey();
16588
+ // A draw that failed part-way, here or anywhere else, left the feed unfinished: it is drawn again whatever the key says.
16589
+ if (feedKey === null || feedKey !== state.feedPollKey || !state.feedDrawn) { paintEvents(); state.feedPollKey = feedKey; }
16590
+ else {
16591
+ try { refreshFeedCards(); } catch (error) { console.warn('floless: the chat cards could not read their state again', error); }
16592
+ }
16593
+ updateSendState();
16594
+ }
16285
16595
  if (state.historyOpen && state.historyFilter === 'instructor-answers') refreshInstructorAnswers();
16286
16596
  } catch { /* SSE or the next poll will recover */ }
16287
16597
  }
16288
16598
 
16599
+ // #3095: what the conversation shows, outside its cards, that can change without anything painting it: the record (its
16600
+ // active turn, state, approval), who answers and whether it is ready, a sign-in window, the live connection, the events.
16601
+ // The cards keep themselves current (refreshFeedCards). Everything else that changes the feed (a streamed word, a card
16602
+ // answered, a source checked) repaints it itself. A record that cannot be written down has no key, and the poll
16603
+ // repaints as it always did.
16604
+ function feedPollKey() {
16605
+ const last = state.events.at(-1);
16606
+ try {
16607
+ return JSON.stringify([state.chat, state.capability, state.events.length, last?.eventId ?? null, last?.sequence ?? null,
16608
+ Boolean(state.chat?.provider && state.signInPending.has(state.chat.provider)), state.source?.readyState ?? null]);
16609
+ } catch { return null; }
16610
+ }
16611
+
16612
+ // #3095: what the redraw on every poll did for the cards, without the redraw: the request cards read their live state,
16613
+ // and every card is drawn again in place (refreshFeedCardsInPlace).
16614
+ function refreshFeedCards() {
16615
+ void refreshRequestCards();
16616
+ refreshFeedCardsInPlace();
16617
+ }
16618
+
16289
16619
  // #1657: FloLess's own copy of this conversation's AI can be moved away, or start re-installing, while
16290
16620
  // the conversation is open — and nothing else re-reads the capability, so the chat kept an enabled
16291
16621
  // Send and no setup card. The managed-runtimes read is cheap (no CLI launch). Only when this AI's copy