@allbluecn/web-app 0.27.41 → 0.28.1

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 (342) hide show
  1. package/package.json +4 -3
  2. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  3. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  4. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  5. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  6. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  7. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  8. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  9. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  10. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  11. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  12. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  13. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  14. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  15. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  16. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  17. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  18. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  19. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  20. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  21. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  22. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  23. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  24. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  25. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  26. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  27. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  28. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  29. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  30. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  31. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  32. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  33. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  34. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  35. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  36. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  37. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  38. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  39. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  40. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  41. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  42. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  43. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  44. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  45. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  46. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  47. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  48. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  49. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  50. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  51. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  52. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  53. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  54. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  55. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  56. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  57. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  58. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  59. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  60. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  61. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  62. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  63. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  64. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  65. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  66. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  67. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  68. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  69. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  70. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  71. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  72. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  73. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  74. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  75. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  76. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  77. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  78. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  79. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  80. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  81. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  82. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  83. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  84. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  85. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  86. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  87. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  88. package/public/pdfjs/cmaps/H.bcmap +0 -0
  89. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  90. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  91. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  92. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  93. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  94. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  95. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  96. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  97. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  98. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  99. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  100. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  101. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  102. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  103. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  104. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  105. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  106. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  107. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  108. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  109. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  110. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  111. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  112. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  113. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  114. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  115. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  116. package/public/pdfjs/cmaps/LICENSE +36 -0
  117. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  118. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  119. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  120. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  121. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  122. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  123. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  124. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  125. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  126. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  127. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  128. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  129. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  130. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  131. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  132. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  133. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  134. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  135. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  136. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  137. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  138. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  139. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  140. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  141. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  142. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  143. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  144. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  145. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  146. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  147. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  148. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  149. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  150. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  151. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  152. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  153. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  154. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  155. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  156. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  157. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  158. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  159. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  160. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  161. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  162. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  163. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  164. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  165. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  166. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  167. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  168. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  169. package/public/pdfjs/cmaps/V.bcmap +0 -0
  170. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  171. package/src/components/ai/ai-prompt-input/index.tsx +3 -87
  172. package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
  173. package/src/components/ai-elements/context.tsx +182 -94
  174. package/src/components/ai-elements/prompt-input.tsx +6 -104
  175. package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
  176. package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
  177. package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
  178. package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
  179. package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
  180. package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
  181. package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
  182. package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
  183. package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
  184. package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
  185. package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
  186. package/src/components/harness/__tests__/dock-registry.test.ts +46 -0
  187. package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
  188. package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
  189. package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
  190. package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
  191. package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
  192. package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
  193. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
  194. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
  195. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
  196. package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
  197. package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
  198. package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
  199. package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
  200. package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
  201. package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
  202. package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
  203. package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
  204. package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
  205. package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
  206. package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
  207. package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
  208. package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
  209. package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
  210. package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
  211. package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
  212. package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
  213. package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
  214. package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
  215. package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
  216. package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
  217. package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
  218. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
  219. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
  220. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
  221. package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
  222. package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
  223. package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
  224. package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
  225. package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
  226. package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
  227. package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
  228. package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
  229. package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
  230. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
  231. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
  232. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
  233. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
  234. package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
  235. package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
  236. package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
  237. package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
  238. package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
  239. package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
  240. package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
  241. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-chat-adapter.test.ts +20 -0
  242. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
  243. package/src/components/harness/conversation-panel/messages/harness-chain/use-agent-terminals.ts +116 -0
  244. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +43 -11
  245. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +25 -4
  246. package/src/components/harness/conversation-panel/messages/tools/__tests__/tool-run.test.ts +26 -1
  247. package/src/components/harness/conversation-panel/messages/tools/tool-run.ts +11 -0
  248. package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
  249. package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
  250. package/src/components/harness/extension-panel/dock/__tests__/tab-strip.test.tsx +45 -0
  251. package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
  252. package/src/components/harness/extension-panel/dock/dock-registry.ts +69 -14
  253. package/src/components/harness/extension-panel/dock/dock-surface.tsx +35 -0
  254. package/src/components/harness/extension-panel/dock/guide-page.tsx +78 -45
  255. package/src/components/harness/extension-panel/dock/tab-strip.tsx +9 -1
  256. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  257. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  258. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  259. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  260. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  261. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  262. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  263. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  264. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  265. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  266. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  267. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  268. package/src/components/harness/extension-panel/panels/terminal/__tests__/kind.test.tsx +219 -2
  269. package/src/components/harness/extension-panel/panels/terminal/__tests__/terminal-instance.test.tsx +322 -19
  270. package/src/components/harness/extension-panel/panels/terminal/__tests__/use-agent-terminal-roster.test.tsx +393 -0
  271. package/src/components/harness/extension-panel/panels/terminal/__tests__/ws-transport.test.ts +25 -0
  272. package/src/components/harness/extension-panel/panels/terminal/kind.tsx +55 -1
  273. package/src/components/harness/extension-panel/panels/terminal/shell-pref.ts +7 -4
  274. package/src/components/harness/extension-panel/panels/terminal/sse-transport.ts +26 -6
  275. package/src/components/harness/extension-panel/panels/terminal/tab-control-state.tsx +114 -0
  276. package/src/components/harness/extension-panel/panels/terminal/terminal-instance.tsx +190 -96
  277. package/src/components/harness/extension-panel/panels/terminal/terminal-theme.ts +113 -0
  278. package/src/components/harness/extension-panel/panels/terminal/transport.ts +28 -6
  279. package/src/components/harness/extension-panel/panels/terminal/use-agent-terminal-roster.ts +107 -0
  280. package/src/components/harness/extension-panel/panels/terminal/ws-transport.ts +7 -5
  281. package/src/components/harness/extension-panel/panels/terminal/xterm-terminal.tsx +5 -67
  282. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  283. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  284. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  285. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  286. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  287. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  288. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  289. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  290. package/src/components/tiptap/node/mention-extension.ts +33 -0
  291. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  292. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  293. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  294. package/src/lib/changelog/sdk-versions.ts +2 -2
  295. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  296. package/src/lib/queries/harness-terminal.ts +77 -0
  297. package/src/lib/queries/harness.ts +50 -0
  298. package/src/paraglide/messages/_index.js +1622 -311
  299. package/src/paraglide/messages/en.js +528 -103
  300. package/src/paraglide/messages/zh.js +529 -104
  301. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  302. package/src/routes/api/harness/$.ts +19 -2
  303. package/src/routes/api/harness/terminal/$.ts +37 -6
  304. package/src/routes/api/harness/terminal/__tests__/route.test.ts +120 -0
  305. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  306. package/src/server/harness/__tests__/agent-terminal.server.test.ts +448 -0
  307. package/src/server/harness/__tests__/builtin-tools-invariant.test.ts +22 -12
  308. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  309. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  310. package/src/server/harness/__tests__/first-contact-fakes.test.ts +103 -3
  311. package/src/server/harness/__tests__/terminal-manager.server.test.ts +761 -2
  312. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  313. package/src/server/harness/agent-terminal.server.ts +631 -0
  314. package/src/server/harness/define.server.ts +21 -3
  315. package/src/server/harness/first-contact-fakes.ts +115 -4
  316. package/src/server/harness/host.server.ts +28 -1
  317. package/src/server/harness/persistence/__tests__/session-index-store.server.test.ts +83 -0
  318. package/src/server/harness/persistence/prisma-persistence.server.ts +12 -3
  319. package/src/server/harness/persistence/session-index-store.server.ts +26 -0
  320. package/src/server/harness/plugins/__tests__/assemble-disable.test.ts +25 -17
  321. package/src/server/harness/plugins/__tests__/tool-risk-audit.test.ts +16 -6
  322. package/src/server/harness/plugins/assemble-app.ts +12 -0
  323. package/src/server/harness/plugins/base-patch.ts +9 -2
  324. package/src/server/harness/plugins/builtin/__tests__/agent-terminal.plugin.test.ts +702 -0
  325. package/src/server/harness/plugins/builtin/agent-terminal.plugin.ts +518 -0
  326. package/src/server/harness/terminal-frame-builder.server.ts +5 -3
  327. package/src/server/harness/terminal-manager.server.ts +772 -35
  328. package/src/server/harness/terminal-ws-handler.server.ts +8 -2
  329. package/src/server/harness/thread-reference.server.ts +446 -0
  330. package/src/server/harness/tool-risk.ts +20 -4
  331. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  332. package/src/server/serverFns/chat/conversations.ts +18 -3
  333. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  334. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  335. package/src/shared/harness/thread-reference-format.ts +98 -0
  336. package/LICENSE +0 -661
  337. package/src/components/agents/slash-skill-menu.tsx +0 -75
  338. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  339. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  340. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  341. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
  342. package/src/components/harness/extension-panel/panels/terminal/__tests__/xterm-webgl.test.ts +0 -68
@@ -0,0 +1,195 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * @file file chip 点击打开 files dock(任务 6):
20
+ * 插入的 file chip 是 `span[data-type=mention][data-path]`。点击该 chip 应经
21
+ * composer-editor 的 editorProps.handleClick → dockRegistry.openResource,以
22
+ * `thread-file:<rawThreadId>/<path>` URI 打开对应文件(非 openKind('files'))。
23
+ *
24
+ * 测试策略:渲染真实 ComposerEditor(真实 TipTap),insertContent 注入 file mention
25
+ * 节点,模拟点击 chip,断言被 mock 的 dockRegistry.openResource 收到 `thread-file:` URI。
26
+ *
27
+ * jsdom 无布局:ProseMirror 的 handleClick 走 mousedown→mouseup 序列并经
28
+ * view.posAtCoords(依赖 elementFromPoint / caretRangeFromPoint / getBoundingClientRect,
29
+ * jsdom 全缺失)解析点击坐标到 doc pos。故本文件局部桩三处几何 API(仅作用于本文件),
30
+ * 再派发 mousedown→mouseup→click 完整序列——否则 handleClick 永不触发(已实测:
31
+ * 裸 fireEvent.click 调用数为 0)。
32
+ */
33
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
34
+ import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"
35
+ import type { Editor } from "@tiptap/core"
36
+
37
+ import { ComposerEditor } from "../composer-editor"
38
+ import { setQueryClient, getQueryClient } from "@/lib/query-client-seam"
39
+ import { QueryClient } from "@tanstack/react-query"
40
+
41
+ // dock-registry 模块 spy:openResource 是被测唯一副作用出口(点击 file chip 走它,非 openKind)
42
+ vi.mock("@/components/harness/extension-panel/dock/dock-registry", () => ({
43
+ dockRegistry: { openResource: vi.fn() },
44
+ }))
45
+ vi.mock("@/server/serverFns/harness/thread-workspace-files", () => ({
46
+ listThreadWorkspaceDirFn: vi.fn(),
47
+ }))
48
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
49
+ vi.mock("@/components/billing/use-feature", () => ({
50
+ useFeature: () => ({ enabled: true, loading: false }),
51
+ }))
52
+ vi.mock("../mention/use-mention-sources", () => ({
53
+ useMentionSources: () => ({ all: [], isLoading: false }),
54
+ }))
55
+
56
+ import { dockRegistry } from "@/components/harness/extension-panel/dock/dock-registry"
57
+ import { buildThreadFileUri } from "@/components/harness/extension-panel/dock/resource-uri"
58
+
59
+ const openResourceMock = vi.mocked(dockRegistry.openResource)
60
+
61
+ beforeEach(() => {
62
+ sessionStorage.clear()
63
+ openResourceMock.mockClear()
64
+ setQueryClient(new QueryClient())
65
+ })
66
+ afterEach(() => {
67
+ cleanup()
68
+ restoreGeometryStubs()
69
+ getQueryClient().clear()
70
+ })
71
+
72
+ /** 渲染 ComposerEditor 并返回就绪的 editor 实例 + 挂载容器 */
73
+ async function renderEditor(rawThreadId: string | null) {
74
+ const holder: { current: Editor | null } = { current: null }
75
+ const { container } = render(
76
+ <ComposerEditor
77
+ threadId={rawThreadId ?? "default"}
78
+ rawThreadId={rawThreadId}
79
+ editable
80
+ onTextChange={() => {}}
81
+ editorRef={(e) => {
82
+ holder.current = e
83
+ }}
84
+ />,
85
+ )
86
+ await waitFor(() => expect(holder.current).not.toBeNull())
87
+ return { editor: holder.current!, container }
88
+ }
89
+
90
+ /**
91
+ * 在无布局的 jsdom 下触发 chip 点击,走真实 ProseMirror handleClick 链路。
92
+ * 局部桩三处几何 API + 派发 mousedown→mouseup→click 完整序列(裸 click 不触发,已实测)。
93
+ * 桩采用保存原值 + afterEach 还原(测试卫生,任务 B 遗留清理 6):避免污染同
94
+ * worker 内后续测试文件的 document/原型链几何 API。
95
+ */
96
+ type StubRestorer = () => void
97
+ const pendingRestores: StubRestorer[] = []
98
+
99
+ /** 覆写属性前保存原描述符(无原值则删除自造属性),注册进 pendingRestores */
100
+ function stubProperty(target: object, key: string, value: unknown): void {
101
+ const desc = Object.getOwnPropertyDescriptor(target, key)
102
+ pendingRestores.push(() => {
103
+ if (desc) Object.defineProperty(target, key, desc)
104
+ else delete (target as Record<string, unknown>)[key]
105
+ })
106
+ Object.defineProperty(target, key, { configurable: true, writable: true, value })
107
+ }
108
+
109
+ function restoreGeometryStubs(): void {
110
+ while (pendingRestores.length) pendingRestores.pop()?.()
111
+ }
112
+
113
+ function clickChip(chip: HTMLElement, editorDom: HTMLElement) {
114
+ const rect = {
115
+ top: 0,
116
+ bottom: 20,
117
+ left: 0,
118
+ right: 200,
119
+ width: 200,
120
+ height: 20,
121
+ x: 0,
122
+ y: 0,
123
+ toJSON() {},
124
+ } as DOMRect
125
+ stubProperty(editorDom, "getBoundingClientRect", () => rect)
126
+ stubProperty(chip, "getBoundingClientRect", () => rect)
127
+ stubProperty(document, "elementFromPoint", () => chip)
128
+ stubProperty(document, "caretRangeFromPoint", () => {
129
+ const r = document.createRange()
130
+ r.setStart(chip, 0)
131
+ r.setEnd(chip, 0)
132
+ return r
133
+ })
134
+ const coords = { clientX: 10, clientY: 10, button: 0, bubbles: true }
135
+ fireEvent.mouseDown(chip, coords)
136
+ fireEvent.mouseUp(chip, coords)
137
+ fireEvent.click(chip, coords)
138
+ }
139
+
140
+ /** 向编辑器插入一个 file mention chip(attrs.path → renderHTML 输出 data-path) */
141
+ function insertFileChip(editor: Editor, path: string) {
142
+ editor.commands.insertContent({
143
+ type: "mention",
144
+ attrs: {
145
+ id: path,
146
+ label: path,
147
+ path,
148
+ mentionSuggestionChar: "@",
149
+ },
150
+ })
151
+ }
152
+
153
+ function getChip(container: HTMLElement, path: string): HTMLElement {
154
+ const chip = container.querySelector<HTMLElement>(
155
+ `span[data-type="mention"][data-path="${path}"]`,
156
+ )
157
+ if (!chip) throw new Error(`file chip 未找到:${path}`)
158
+ return chip
159
+ }
160
+
161
+ describe("file chip 点击打开 files dock(任务 6)", () => {
162
+ it("点击 file chip → openResource 收到 thread-file:<rawThreadId>/<path> URI", async () => {
163
+ const { editor, container } = await renderEditor("t1")
164
+ insertFileChip(editor, "src/a.ts")
165
+ const chip = getChip(container, "src/a.ts")
166
+ const editorDom = container.querySelector<HTMLElement>(".tiptap.ProseMirror")!
167
+ clickChip(chip, editorDom)
168
+ const expected = buildThreadFileUri("t1", "src/a.ts")
169
+ expect(expected).toBe("thread-file:t1/src/a.ts")
170
+ expect(openResourceMock).toHaveBeenCalledTimes(1)
171
+ expect(openResourceMock).toHaveBeenCalledWith(expected)
172
+ })
173
+
174
+ it("点击非 chip 区域(纯文本)→ openResource 不被调", async () => {
175
+ const { editor, container } = await renderEditor("t1")
176
+ editor.commands.insertContent("plain text no chip")
177
+ const editorDom = container.querySelector<HTMLElement>(".tiptap.ProseMirror")!
178
+ const chip = container.querySelector<HTMLElement>('span[data-type="mention"]')
179
+ expect(chip).toBeNull()
180
+ // 点编辑器内任意段落(无 chip 祖先)
181
+ const p = editorDom.querySelector("p")!
182
+ clickChip(p as HTMLElement, editorDom)
183
+ expect(openResourceMock).not.toHaveBeenCalled()
184
+ })
185
+
186
+ it("rawThreadId 为 null(会话未建立空态)→ 点击 chip 不打开(gating)", async () => {
187
+ const { editor, container } = await renderEditor(null)
188
+ // 空态下 @ 菜单 file 源恒空,但 chip 可由历史草稿恢复而来——直接注入验证 handleClick gating
189
+ insertFileChip(editor, "src/b.ts")
190
+ const chip = getChip(container, "src/b.ts")
191
+ const editorDom = container.querySelector<HTMLElement>(".tiptap.ProseMirror")!
192
+ clickChip(chip, editorDom)
193
+ expect(openResourceMock).not.toHaveBeenCalled()
194
+ })
195
+ })
@@ -0,0 +1,107 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * MenuView isCurrent opt-in prop(2026-11-20 任务 B 遗留清理 3):popup 型浮层
20
+ * (/model、/permission)的高亮行是 selectedIndex=-1(无键盘高亮),「当前档」
21
+ * 语义此前只有 ✓ 图标 + font-semibold,无 aria-selected——屏幕阅读器读不出当前档。
22
+ * isCurrent 谓词命中行 → aria-selected=true(与 isSelected 取或,不覆盖键盘高亮);
23
+ * 缺省 undefined = 无当前档语义,零变化('/' 菜单 / @ 菜单不受影响)。
24
+ */
25
+ import { afterEach, describe, expect, it, vi } from "vitest"
26
+ import { cleanup, render } from "@testing-library/react"
27
+
28
+ import { MenuView, type MenuViewEntry } from "../command/menu-view"
29
+
30
+ afterEach(cleanup)
31
+
32
+ const entries: ReadonlyArray<MenuViewEntry<string>> = [
33
+ { key: "a", groupLabel: "G", item: "a" },
34
+ { key: "b", groupLabel: "G", item: "b" },
35
+ ]
36
+
37
+ function getRows(): HTMLElement[] {
38
+ return Array.from(document.querySelectorAll<HTMLElement>('[role="option"]'))
39
+ }
40
+
41
+ describe("MenuView isCurrent(popup 当前档 aria-selected)", () => {
42
+ it("isCurrent 命中行 → aria-selected=true;未命中行 false(键盘高亮 selectedIndex=-1)", () => {
43
+ render(
44
+ <MenuView
45
+ entries={entries}
46
+ selectedIndex={-1}
47
+ onSelect={() => {}}
48
+ selector="test-popup"
49
+ isCurrent={(item) => item === "a"}
50
+ renderTitle={(item) => item}
51
+ />,
52
+ )
53
+ const rows = getRows()
54
+ expect(rows).toHaveLength(2)
55
+ expect(rows[0].getAttribute("aria-selected")).toBe("true")
56
+ expect(rows[1].getAttribute("aria-selected")).toBe("false")
57
+ })
58
+
59
+ it("缺省(不传 isCurrent)→ 全行 aria-selected=false(零变化)", () => {
60
+ render(
61
+ <MenuView
62
+ entries={entries}
63
+ selectedIndex={-1}
64
+ onSelect={() => {}}
65
+ selector="test-popup"
66
+ renderTitle={(item) => item}
67
+ />,
68
+ )
69
+ for (const row of getRows()) {
70
+ expect(row.getAttribute("aria-selected")).toBe("false")
71
+ }
72
+ })
73
+
74
+ it("isCurrent 与键盘高亮取或:高亮行 aria-selected=true 不被覆盖", () => {
75
+ render(
76
+ <MenuView
77
+ entries={entries}
78
+ selectedIndex={1}
79
+ onSelect={() => {}}
80
+ selector="test-popup"
81
+ isCurrent={(item) => item === "a"}
82
+ renderTitle={(item) => item}
83
+ />,
84
+ )
85
+ const rows = getRows()
86
+ expect(rows[0].getAttribute("aria-selected")).toBe("true")
87
+ expect(rows[1].getAttribute("aria-selected")).toBe("true")
88
+ })
89
+
90
+ it("isCurrent 命中行点击 → onSelect 收到该条目(选中链路不受 isCurrent 影响)", () => {
91
+ const onSelect = vi.fn()
92
+ render(
93
+ <MenuView
94
+ entries={entries}
95
+ selectedIndex={-1}
96
+ onSelect={onSelect}
97
+ selector="test-popup"
98
+ isCurrent={(item) => item === "b"}
99
+ renderTitle={(item) => item}
100
+ />,
101
+ )
102
+ // Item(ui/item)根元素持有 onClick——行内第一个元素即 Item 根
103
+ const itemEl = getRows()[1].firstElementChild
104
+ itemEl?.dispatchEvent(new MouseEvent("click", { bubbles: true }))
105
+ expect(onSelect).toHaveBeenCalledExactlyOnceWith("b")
106
+ })
107
+ })
@@ -0,0 +1,271 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * 附件信封预检锁定(P1 任务 6):submitClaim 结算守卫(harness-composer E2 结算守卫,
20
+ * `acceptsAttachments !== true && attachments.length > 0` → 拒绝结算)回归锁定。
21
+ *
22
+ * - 拒绝路径:claim 态 chip(server input 命令未声明 acceptsAttachments)+ 附件轨道
23
+ * 非空 → Enter 结算被拒:toast(含命令名)+ 草稿保留(chip 仍在 doc——仍 claimed)
24
+ * + 附件不清 + onRunCommand 不调 + 不回落普通发送(onSend 不调)。
25
+ * - 放行路径:server 命令声明 acceptsAttachments: true → 结算放行:onRunCommand(name,
26
+ * args) 调 + 结算成功清附件(clearAttachments)+ chip 清除(idle)。
27
+ * - 无附件基线:claim 态无附件 → 守卫不触发,正常结算(防守卫误伤)。
28
+ * - uploading 态附件同样拦截:守卫读整个附件轨道(useAttachments state),非仅 ready。
29
+ *
30
+ * 渲染面:HarnessComposer(真实 TipTap)。claimed 态构造不走 '/' 菜单选中(组件级
31
+ * 交互重),改经 draftsStore 预置 claimed doc JSON(ComposerEditor 挂载时
32
+ * resolveInitialContent 回放草稿——chip 是注册节点,JSON 逐字构造形状同
33
+ * claim-guard.test.tsx claimedDoc)。附件经 mock useAttachments 注入(托盘渲染真实
34
+ * Attachment chip,断言可落 DOM)。Enter 经 fireEvent.keyDown 直发编辑器 DOM
35
+ * (jsdom 无真实键盘;无菜单打开,keymap 直达提交入口)。
36
+ */
37
+ import { afterEach, beforeEach, expect, it, vi } from "vitest"
38
+ import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"
39
+ import { HarnessComposer } from "../../harness-composer"
40
+ import { clearComposerExtensions } from "../../extension"
41
+ import { toast } from "@/components/ui/toast"
42
+ import { m } from "@/paraglide/messages.js"
43
+ import type { ComposerServerCommand } from "../../extension"
44
+ import type { Attachment } from "../../attachments/use-attachments"
45
+ import type { JSONContent } from "@tiptap/react"
46
+
47
+ vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
48
+ vi.mock("../../mention/use-mention-sources", () => ({
49
+ useMentionSources: () => ({ all: [], isLoading: false }),
50
+ }))
51
+ vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
52
+ vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
53
+ // mock 链切断(T9):command-popup 经 permission-policy 访问沙箱策略——真模块顶层
54
+ // import sandbox-policy serverFn → policy index(上方 throw 守卫),桩掉即断链
55
+ vi.mock("../../permission/permission-policy", () => ({
56
+ SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
57
+ getSandboxPolicy: vi.fn(),
58
+ setSandboxPolicy: vi.fn(),
59
+ }))
60
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
61
+ vi.mock("@/components/harness/conversation-panel/messages/approvals/interrupt-approval", () => ({ InterruptApproval: () => null }))
62
+ vi.mock("@/components/ui/toast", () => ({
63
+ toast: {
64
+ error: vi.fn(),
65
+ success: vi.fn(),
66
+ info: vi.fn(),
67
+ warning: vi.fn(),
68
+ loading: vi.fn(),
69
+ message: vi.fn(),
70
+ dismiss: vi.fn(),
71
+ promise: vi.fn(),
72
+ },
73
+ }))
74
+
75
+ // 附件轨道 mock(useAttachments 是 HarnessComposer 内部 hook,无 prop 注入口):
76
+ // holder 挂 vi.hoisted 保工厂闭包可用;clear spy 断言「结算成功清附件」通路。
77
+ const attachmentsMock = vi.hoisted(() => {
78
+ const list: Attachment[] = []
79
+ return { list, clear: vi.fn() }
80
+ })
81
+ vi.mock("../../attachments/use-attachments", () => ({
82
+ useAttachments: () => ({
83
+ attachments: attachmentsMock.list,
84
+ addFiles: vi.fn(),
85
+ removeAttachment: vi.fn(),
86
+ clearAttachments: attachmentsMock.clear,
87
+ retryAttachment: vi.fn(),
88
+ hasPending: false,
89
+ }),
90
+ }))
91
+
92
+ const DRAFTS_KEY = "allblue.harness.drafts"
93
+
94
+ beforeEach(() => {
95
+ sessionStorage.clear()
96
+ attachmentsMock.list = []
97
+ attachmentsMock.clear.mockClear()
98
+ vi.mocked(toast.info).mockClear()
99
+ })
100
+ afterEach(() => {
101
+ cleanup()
102
+ clearComposerExtensions()
103
+ })
104
+
105
+ /** 附件轨道条目(mock 注入;file/previewUrl 为托盘渲染所需最小形状) */
106
+ function fakeAttachment(status: Attachment["status"]): Attachment {
107
+ return {
108
+ id: `att-${status}`,
109
+ file: new File(["x"], "a.png", { type: "image/png" }),
110
+ previewUrl: `blob:mock-${status}`,
111
+ status,
112
+ }
113
+ }
114
+
115
+ /** 行首 commandChip 的 claimed doc(claim-guard.test.tsx claimedDoc 同款形状) */
116
+ function claimedDoc(name: string, args: string): JSONContent {
117
+ return {
118
+ type: "doc",
119
+ content: [
120
+ {
121
+ type: "paragraph",
122
+ content: [
123
+ { type: "commandChip", attrs: { name, label: name, hint: "描述参数…" } },
124
+ ...(args ? [{ type: "text", text: ` ${args}` }] : []),
125
+ ],
126
+ },
127
+ ],
128
+ }
129
+ }
130
+
131
+ /** 预置 claimed 草稿(ComposerEditor 挂载经 draftsStore.load 回放——draftKey = draft:<threadId>) */
132
+ function seedClaimedDraft(threadId: string, doc: JSONContent): void {
133
+ sessionStorage.setItem(DRAFTS_KEY, JSON.stringify({ [`draft:${threadId}`]: JSON.stringify(doc) }))
134
+ }
135
+
136
+ interface SetupOptions {
137
+ chipName: string
138
+ args: string
139
+ commands?: ReadonlyArray<ComposerServerCommand>
140
+ attachments?: Attachment[]
141
+ }
142
+
143
+ interface SetupResult {
144
+ onSend: ReturnType<typeof vi.fn>
145
+ onRunCommand: ReturnType<typeof vi.fn>
146
+ }
147
+
148
+ /** 挂载 HarnessComposer:无 prefill(预置草稿接管)+ mock server 命令 + 附件轨道注入 */
149
+ function setup(options: SetupOptions): SetupResult {
150
+ seedClaimedDraft("t1", claimedDoc(options.chipName, options.args))
151
+ if (options.attachments) attachmentsMock.list = options.attachments
152
+ const onSend = vi.fn()
153
+ const onRunCommand = vi.fn()
154
+ render(
155
+ <HarnessComposer
156
+ threadId="t1"
157
+ isRunning={false}
158
+ hasAiKey
159
+ busyPreference="queue"
160
+ onSend={onSend}
161
+ onStop={vi.fn()}
162
+ conversationRegionRef={{ current: null }}
163
+ messages={[]}
164
+ commands={options.commands}
165
+ onRunCommand={onRunCommand}
166
+ />,
167
+ )
168
+ return { onSend, onRunCommand }
169
+ }
170
+
171
+ function getEditorDom(): HTMLElement {
172
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
173
+ if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
174
+ return el
175
+ }
176
+
177
+ /** chip 节点 DOM(commandChip renderHTML;null = doc 已无 chip——idle) */
178
+ function getChipDom(name: string): HTMLElement | null {
179
+ return document.querySelector<HTMLElement>(`[data-command-chip][data-chip-name="${name}"]`)
180
+ }
181
+
182
+ /** 附件托盘 chip(官方 Attachment 家族按 mocked 条目渲染;null = 托盘空) */
183
+ function getAttachmentDom(): HTMLElement | null {
184
+ return document.querySelector<HTMLElement>('img[alt="a.png"]')
185
+ }
186
+
187
+ it("拒绝结算:claim 态 + 附件轨道非空 → toast + 草稿保留(仍 claimed)+ 附件不清 + 不执行不发送", async () => {
188
+ // server input 命令未声明 acceptsAttachments(缺省 false)——守卫应拦
189
+ const { onSend, onRunCommand } = setup({
190
+ chipName: "plan",
191
+ args: "参数",
192
+ commands: [{ name: "plan", description: "规划", input: true }],
193
+ attachments: [fakeAttachment("ready")],
194
+ })
195
+ // 前置:claimed doc 回放成功(chip 在 doc 中)+ 托盘非空
196
+ await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
197
+ expect(getAttachmentDom()).not.toBeNull()
198
+
199
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
200
+
201
+ // toast(含命令名)
202
+ expect(toast.info).toHaveBeenCalledExactlyOnceWith(
203
+ m.harness_command_claimAttachmentsUnsupported({ command: "plan" }),
204
+ )
205
+ // 草稿保留:chip 仍在 doc(仍 claimed,可改参数或删 chip 退出)
206
+ expect(getChipDom("plan")).not.toBeNull()
207
+ // 附件未被清除(托盘照旧 + clearAttachments 未调)
208
+ expect(getAttachmentDom()).not.toBeNull()
209
+ expect(attachmentsMock.clear).not.toHaveBeenCalled()
210
+ // 结算未执行 + 拒绝不回落普通发送
211
+ expect(onRunCommand).not.toHaveBeenCalled()
212
+ expect(onSend).not.toHaveBeenCalled()
213
+ })
214
+
215
+ it("放行:声明 acceptsAttachments 的 server 命令 → 结算放行(onRunCommand 调 + 附件清除 + chip 清除)", async () => {
216
+ const { onRunCommand } = setup({
217
+ chipName: "export",
218
+ args: "每周汇总",
219
+ commands: [{ name: "export", description: "导出", input: true, acceptsAttachments: true }],
220
+ attachments: [fakeAttachment("ready")],
221
+ })
222
+ await waitFor(() => expect(getChipDom("export")).not.toBeNull(), { timeout: 3000 })
223
+ expect(getAttachmentDom()).not.toBeNull()
224
+
225
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
226
+
227
+ // 结算放行:args 透传(chip 后文本 trim)
228
+ expect(onRunCommand).toHaveBeenCalledExactlyOnceWith("export", "每周汇总")
229
+ // 结算成功路径清附件
230
+ expect(attachmentsMock.clear).toHaveBeenCalledExactlyOnceWith()
231
+ // 草稿清除(同步结算成功 → clearAfterSend → idle)
232
+ await waitFor(() => expect(getChipDom("export")).toBeNull(), { timeout: 3000 })
233
+ expect(toast.info).not.toHaveBeenCalled()
234
+ })
235
+
236
+ it("无附件基线:claim 态无附件 → 守卫不触发,正常结算", async () => {
237
+ const { onSend, onRunCommand } = setup({
238
+ chipName: "plan",
239
+ args: "参数",
240
+ commands: [{ name: "plan", description: "规划", input: true }],
241
+ attachments: [],
242
+ })
243
+ await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
244
+
245
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
246
+
247
+ expect(toast.info).not.toHaveBeenCalled()
248
+ expect(onRunCommand).toHaveBeenCalledExactlyOnceWith("plan", "参数")
249
+ expect(attachmentsMock.clear).toHaveBeenCalledExactlyOnceWith()
250
+ await waitFor(() => expect(getChipDom("plan")).toBeNull(), { timeout: 3000 })
251
+ expect(onSend).not.toHaveBeenCalled()
252
+ })
253
+
254
+ it("uploading 态附件同样拦截:守卫读整个附件轨道(非仅 ready)", async () => {
255
+ const { onRunCommand } = setup({
256
+ chipName: "plan",
257
+ args: "参数",
258
+ commands: [{ name: "plan", description: "规划", input: true }],
259
+ attachments: [fakeAttachment("uploading")],
260
+ })
261
+ await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
262
+
263
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
264
+
265
+ expect(toast.info).toHaveBeenCalledExactlyOnceWith(
266
+ m.harness_command_claimAttachmentsUnsupported({ command: "plan" }),
267
+ )
268
+ expect(getChipDom("plan")).not.toBeNull()
269
+ expect(attachmentsMock.clear).not.toHaveBeenCalled()
270
+ expect(onRunCommand).not.toHaveBeenCalled()
271
+ })